Vwhee
05-23-2012, 07:50 AM
Hi,
I've cobbled together some code that I'm hoping will multiply the cells in a range but only if that cell has content in it. It's part of a larger macro on a very large range of data but I've put together a little example of the data type and the part of the macro that doesn't seem to be working correctly. It's probably something really simple but I can't see where. :help
The Code I'm using is
Sub FindNumbers()
Sheets("Dates sheet").Select
Dim LRng As Range, URng As Range, F1Rng As Range
Dim cl As Variant
Set LRng = Sheets(1).Range("B3")
Set URng = Sheets(1).Range("I31").End(xlUp)
Set F1Rng = Range(LRng, URng)
For Each cl In F1Rng
If cl.Value > 1 Then
cl.Value = cl.Value * 2
End If
Next cl
End Sub
For some reason it works on some of the cells but not others and I'm not sure why.
Attached is the example spreadsheet.
Any help would be greatly appreciated - thank you
Vwhee
I've cobbled together some code that I'm hoping will multiply the cells in a range but only if that cell has content in it. It's part of a larger macro on a very large range of data but I've put together a little example of the data type and the part of the macro that doesn't seem to be working correctly. It's probably something really simple but I can't see where. :help
The Code I'm using is
Sub FindNumbers()
Sheets("Dates sheet").Select
Dim LRng As Range, URng As Range, F1Rng As Range
Dim cl As Variant
Set LRng = Sheets(1).Range("B3")
Set URng = Sheets(1).Range("I31").End(xlUp)
Set F1Rng = Range(LRng, URng)
For Each cl In F1Rng
If cl.Value > 1 Then
cl.Value = cl.Value * 2
End If
Next cl
End Sub
For some reason it works on some of the cells but not others and I'm not sure why.
Attached is the example spreadsheet.
Any help would be greatly appreciated - thank you
Vwhee