[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

RE: Formatting of fields

Jim Jackson

12/12/2006 9:59:00 PM

Hit "Send" too quickly.

To have the macro run whenever a row is added or deleted place it in a macro
named:
Private Sub Worksheet_Change(ByVal Target As Range)
On the sheet in question, right-click the tab and choose "View Code". The
window you must put this macro in will open.

One way to attach a keyboard combination is to record a new macro, even if
you stop recording before doing anything. Give it the keyboard combination
you want and then place your code in that macro.

It also must be in the same window as the Change Event macro.

--
Best wishes,

Jim


"JeffH" wrote:

> HI,
>
> I don't know much about Excel Macros but I'm trying to learn this as best I
> can. I have a macro script that was given to me by another member in this
> forum, I modified it, but it doesn't give me what I want. I need to format
> every 3rd and fourth row with a different color. I found the correct color.
> I also need this macro to reset the row formatting if a column gets added or
> deleted. My question is can I get a suggestion on what to do so that I can
> specify a range of cells versus what's in this script called 'ActiveSheet'.
> Also, can I associate this macro with a keyboard combination?
>
> The code looks like this.
>
> Public Sub RowColor()
>
> Dim c As Range
>
> For Each c In ActiveSheet.Rows
>
> If (c.Row - 2) Mod 4 > 1 Then
>
> c.Interior.ColorIndex = 35
>
> Else: c.Interior.ColorIndex = xlNone
>
> End If
>
> Next c
>
> End Sub
>
>
> Thanks in Advance,
> JeffH