[[20080715111623]] 『A列の3の倍数行の選択』(yone) ページの最後に飛ぶ

[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]

 

『A列の3の倍数行の選択』(yone)

A列の3の倍数行(A3,A6,A9…)に0〜1000の数字が入っています。

A列の3の倍数行かつ0以上のセルの選択方法ってありますでしょうか??

3の倍数ってナベアツみたいですケド(・ ・;)

よろしくお願いします!!!


 > セルの選択方法
 たぶんマクロになると思いますが、セルを選択して、何をしたいのですか?
 計算ならSumproduct関数かもしれませんね。  (Hatch)

 こんな感じになるでしょうか。(ROUGE)
'----
Sub test()
Dim txt() As String
Dim i As Long
Dim rng As Range
ReDim txt(0)
With CreateObject("VBScript.RegExp")
    .Pattern = "^\d+(\.\d+)?$"
    For i = 3 To Rows.Count Step 3
        If .test(Cells(i, 1).Value) Then
            If Cells(i, 1).Value >= 0 Then txt(UBound(txt)) = _
                txt(UBound(txt)) & Cells(i, 1).Address(0, 0) & ","
        End If
        If Len(txt(UBound(txt))) > 245 Then
            txt(UBound(txt)) = Left(txt(UBound(txt)), Len(txt(UBound(txt))) - 1)
            ReDim Preserve txt(UBound(txt) + 1)
        End If
    Next
End With
If Len(txt(UBound(txt))) > 0 Then txt(UBound(txt)) = Left(txt(UBound(txt)), Len(txt(UBound(txt))) - 1)
If UBound(txt) > 0 Then
    For i = 0 To UBound(txt) - IIf(Len(txt(UBound(txt))) > 0, 0, 1)
        If i = 0 Then
            Set rng = Range(txt(i))
        Else
            Set rng = Union(rng, Range(txt(i)))
        End If
    Next
Else
    If Len(txt(0)) > 0 Then Set rng = Range(txt(0))
End If
If Not rng Is Nothing Then rng.Select
End Sub


お世話になります。

セルを選択して、単位のsを付けたいんですよ。

A1,A4,A7・・・には品名
A2,A5,A8・・・には納入先が入っているんで、
A3,A6,A9・・・の重要だけ選択して書式設定でKGを加えようと思っているんです。


 品名と納入先は文字列でしょうから、単にA列のユーザー定義  0"kg" (整数の場合)
 でいいんじゃないのかな。。。(xxx)


皆さんありがとうございます。

大変参考になりました。


コメント返信:

[ 一覧(最新更新順) ]


YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki. Modified by kazu.