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
Else
GoTo NextCol:
End If
Next X
NextCol:
Next Y
End Sub


Thanks.,

TAMATAM

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts