View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 292
Default Macro help required!

Hi Don

Sub test()
Dim myRange As Range, MyCel As Range
Set myRange = Range("B4:B17")
For Each MyCel In myRange.Cells
If MyCel.Value = "RED" Then
'stuff...
End If
Next
End Sub

This is good:
http://www.j-walk.com/ss/books/xlbook25.htm

HTH. Best wishes Harald


"Don Niall" skrev i melding
...
Hi - I would appreciate some input on the macro below. I
apologise in advance as I am just getting familiar with
macros. The macro is working but only on the first cell
B4. I need it to step through each cell from B4 to B17,
and do the same procedure ....I am guessing I need some
kine of For/Netxt statement - or some kind of loop
condition? Would really appreciate some help?
(PS Any good resources available - books or others - on
Macros for beginners?)

Don-

Dim myRange As Range
Set myRange = Range("B4:B17")
If myRange.Value = "RED" Then
With myRange
.Offset(0, -1).Value = ClearContents
.Offset(0, 1).Value = 0
.Offset(0, 2).Value = 0
.Offset(0, 4).Value = 0
End With
End If
End Sub