Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through Excel columns? 3

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hi
How do I loop through Excel columns? IE how do I read all the values from row 1 say...
Can I do
For i: A to IV ?
 
Something like this ?
For Each c In Range("A1:IV1")
MsgBox c.Address & " = " & c.Value
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
or:

for i = 1 to 256
msgbox "Val:" & cells(1,i).value
next i

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
or:
dim rngObj as range

set rngobj = Range ("A1:B2")

for each c in rngobj.columns

next c

there are several ways to determine the working range. this is another, which cycles through ALL the columns on the sheet

Dim c As Range

For Each c In ActiveSheet.Columns
c.Cells(1, 1).Value = 1
Next c
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top