Saturday, March 16, 2013

How to Loop Through Each Column in Excel Sheet using VBA Macro

Excel VBA Macro To Paint the Column Walls Up to Empty Brick Found
'This macro Paints Column Wall upto it finds an Empty Cell/Brick ,When it finds an Empty Cell then it Moves to Next Column for Painting.
'We can use this Logic for several purposes in our Real Time Scenario's

Sub Jump2NextCol()
Dim X As Integer
Dim Y As Integer

For Y = 1 To 26 ' Colummns Having Data

For X = 1 To 500 ' Rows having data
If Cells(X, Y) <> "" Then
Cells(X, Y).Interior.ColorIndex = Y + 35 'Add colors
Else
GoTo NextCol:
End If
Next X
NextCol:
Next Y
End Sub



Thanks,
TAMATAM

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog