Search : in
By :

Macro for fill color alternative rows

Last answer on Sep 2, 2009 1:07:24 am BST jk, on Aug 28, 2009 2:09:37 pm BST 
 Report this message to moderators

Hello,

I want a macro for fill color alternative rows in excel selected table (only visible rows), anyone can you please help me.

Configuration: Windows XP Internet Explorer 7.0

Best answers for « Macro for fill color alternative rows » in :
[VBA] A function that returns the color of an active MFC Show[VBA] A function that returns the color of an active MFC This function returns the value of the active format in conditional formatting. With the function below, two values can be returned. Mode = 0: the value of Interior.ColorIndex...
Colouring cells on conditions ShowColouring cells on conditions There are many pratical functions under Excel which is not commonly used. Example: If you wish a cell automatically turns red (or other formatting border, frame etc) under one condition: a result, a...
Excel – Macro to detect and hide blank rows ShowExcel – Macro to detect and hide blank rows Issue Solution Note Issue I want a macro to unhide about 20 blank rows copy values into the top row then hide the remaining rows (some cells have fill though) then the next time it will...
Download HP Universal Print Driver (UPD) PCL ShowThe HP UPD drivers (Universal Print Driver) are compatible unified drivers with all the printers of the range of HP LaserJet and HP Color LaserJet. Alternative spelling: HP universal print driver, HP UPD, HP universal printing pcl.
Download Super Macro ShowSuper macro is a free software which allows to create macro under Windows in order to activate diverse automatic actions. Apart being free, this software is easy to use and requires no knowledge in programming. You just simply click buttons, then...

1

venkat1926, on Aug 29, 2009 3:59:20 am BST
  • +1

Try this macro (this will color rows 2,4,6,8 etc red)

Sub test()
Dim j As Integer, k As Integer
j = Range("a1").End(xlDown).Row
'j is the last row
For k = 1 To j
If k Mod 2 = 0 Then
Cells(k, "a").EntireRow.Interior.ColorIndex = 3
End If
Next k
End Sub


if you want rows 1,3,5,7 etc to be colored
change the following line in the above macro
If k Mod 2 = 0 Then
into
If k Mod 2 = 1 Then

Reply to venkat1926

2

jk, on Aug 31, 2009 9:54:29 am BST

Hi,

But, i want to fill color in selected range (any range), which rows are visible (Not Hidden). if my rows are 1 to 10, hidden rows 3 and 6, then visible rows 1,2,4,5,7,8,9,10. now i want to alternate color these visible rows.

Reply to jk

3

venkat1926, on Aug 31, 2009 10:22:53 am BST

Contradiction between first message and laest one. first you want ALTERENATE ROWS to be colored. Now you want ALLTHE unhidden rows to be colored . please rephrase your question.

Reply to venkat1926

4

jk, on Sep 1, 2009 9:58:06 am BST

I'm very sorry for that, I want ALL THE UNHIDDEN rows to be colored. Please help me. thx

Reply to jk

5

venkat1926, on Sep 2, 2009 1:06:02 am BST

Q

Reply to venkat1926

6

 venkat1926, on Sep 2, 2009 1:07:24 am BST

Quote
I want ALL THE UNHIDDEN rows to be colored.
unquote
why do you want to color the unhidden rows. it is always in front of you anyhow try this mcro

Sub test()
Dim j As Integer, k As Integer
j = Range("a1").End(xlDown).Row
'j is the last row
For k = 1 To j
If Rows(k).Hidden = False Then
Cells(k, "a").EntireRow.Interior.ColorIndex = 3
End If
Next k
End Sub

Reply to venkat1926