Quick help, on small macro Problem

Lynxador

Board Regular
Joined
Jan 6, 2005
Messages
125
i have this so far.

Code:
Sub Color_format()
Dim x As Long

For x = 6 To 33697 Step 7
Range("E &x:G &x").Select
Selection.Font.ColorIndex = 2
Next x

End Sub

I'm a beginner programmer.. and i always always forget how to set up the range so it uses x as the second value of a cell. any help would be much appreciated.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I'm not sure what you want but does this work:

Code:
Sub Color_format() 
Dim X As Long 

     For X = 6 To 33697 Step 7 
          Range("E" & X & ":G"  & X).Font.ColorIndex = 2 
     Next X 

End Sub

I removed the Select part as you don't always need that to work with a range.

BTW what are you actually tryikng to do - perhaps there is another approach than using a loop.
 
Upvote 0
Have you tried the code I posted?

Have you tried using Conditional Formatting?
 
Upvote 0
your code worked perfectly for what i needed. thank you norie :) im gonna try conditional formatting next. im just trying to learn different sloutions to the same problem.
 
Upvote 0
Well for the conditional formatting you could try something like this.

Select the range you want to format. goto Format>Conditional Formatting..., select Formula is from the dropdown and try this formula:

=MOD(ROW(E1),7)=0

I don't know if this will do exactly what you want.
 
Upvote 0

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top