Saturday, 16 March 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
GoTo NextCol:
End If
Next X
Next Y
End Sub



No comments:

Post a Comment

Hi User, Thank You for Visiting My Blog. Please Post Your Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts