Automate cell selection

  • Thread starter Thread starter mayanklal
  • Start date Start date
M

mayanklal

Hi,
How do I automate cell selection? For example if I want to select cell
A1,C1 and E1 then A2,C2,E2 and so on,each time using the data stored i
these cells.

Thanks,
Mayank
 
Sub DemoApproach()
Dim i As Long, rng As Range
Dim cell As Range, sStr As String
For i = 1 To 10
Set rng = Cells(i, 1).Range("A1,C1,E1")
' msgbox rng.Address
For Each cell In rng
sStr = sStr & cell.Address(0, 0) & ","
Next
sStr = Left(sStr, Len(sStr) - 1)
sStr = sStr & vbNewLine
Next
MsgBox sStr
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top