|
3セルごとに設定してあると仮定して
Option Explicit
Sub try()
Dim myRng As Range
Dim mystr As String, celad As String, mystr2 As String
Dim mycell As Range
Dim i As Long, n As Long, j As Long
Set myRng = Selection
For i = 0 To myRng.Rows.Count
mystr = ""
For Each mycell In myRng.Resize(1).Offset(i)
If mycell.HorizontalAlignment = 7 Then
mystr = mystr & mycell.Address & ","
End If
Next
If mystr <> "" Then
mystr = "" & Left(mystr, Len(mystr) - 1) & ""
Range(mystr).Select
n = Selection.Count
For j = 1 To n / 3
mystr2 = ActiveCell.Offset(, (j - 1) * 3).Resize(, j * 3).Address
celad = celad & mystr2 & vbCrLf
Next
End If
Next
MsgBox celad
Set myRng = Nothing
End Sub
|
|