PDA

View Full Version : First Time VBA'(er?)



ColinJohnson
11-03-2009, 12:16 PM
Hey All,

I am frustratingly new to VBA and am looking for some help on something.

The goal:
If any cell in AccountRange is equal to the cell 16 columns to it's right Then run a macro. The worksheet_calculate event is the trigger.

What I have so far:
Application.EnableEvents = False
Application.ScreenUpdating = False

Dim AccountRange As Range
Set AccountRange = Sheets("Linked").Range(Range("A1"), Range ("A1").End(xlDown))


For Each Cell In AccountRange
'This is where I have problems coming up with the IF...THEN statement. I just don't know how to reference a generic cell in the range.

Next Cell

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

Thanks in advance for any help you can give.

stanleydgrom
11-03-2009, 01:18 PM
ColinJohnson,

Try:





For Each Cell In AccountRange
If Cell.Value = Cell.Offset(, 16).Value Then Call MyMacro
Next Cell

ColinJohnson
11-03-2009, 02:25 PM
That worked. Thanks stanleydgrom