Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Loop thru excel columns

Hi Shantanu,

When I got the notification of a reply on this thread I see that my answer
was empty except for the auto sign off so here it is again.

The following loops through columns until it comes to a cell in row 1 that
is blank.

You could use a specific column number in lieu of Columns.Count.

I am not really sure what it is you want to do but hope the example helps to
point you in the right direction.

Sub loopThroughColumns()

Dim c As Long

For c = 1 To Columns.Count
If Cells(1, c) < "" Then
MsgBox "Cell " & Cells(1, c).Address
Else
MsgBox "No more data"
Exit For
End If
Next c
End Sub


--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
loop through columns (using for-loop) Kurt[_3_] Excel Programming 2 November 23rd 07 08:56 PM
Loop through columns Geir Holmavatn Excel Programming 3 September 5th 06 04:03 PM
Loop through Columns Sally[_6_] Excel Programming 3 August 26th 06 10:52 AM
loop through columns hotherps[_78_] Excel Programming 6 July 23rd 04 11:40 AM
Excel VBA - loop columns named AA, AB..etc Tobias[_2_] Excel Programming 3 April 19th 04 01:26 PM


All times are GMT +1. The time now is 08:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"