tourless
Board Regular
- Joined
- Feb 8, 2007
- Messages
- 144
- Office Version
- 365
- Platform
- Windows
Hi Folks.
I have copied values in cells M21:R21, but sometimes they might be blank. I need to test for a value and if one is present, place this formula in the cell directly below it.
"=(ROUND(R[-1]C,2),"
I'm not sure how to write the code to accomplish this. but here's what I'm working with... you can see the mess I'm making and I bet this can also be done without the selects.
I have copied values in cells M21:R21, but sometimes they might be blank. I need to test for a value and if one is present, place this formula in the cell directly below it.
"=(ROUND(R[-1]C,2),"
I'm not sure how to write the code to accomplish this. but here's what I'm working with... you can see the mess I'm making and I bet this can also be done without the selects.
VBA Code:
For Each cell In Range("M21:R21")
If cell <> "" Then
Range("M22").FormulaR1C1 = "=(ROUND(R[-1]C,2),"
Else
Range("M22").FormulaR1C1 = "=IFERROR(ROUND(R[-1]C,2),"",=(ROUND(R[-1]C,2)"
Range("M22").Copy
Range("N22:R22").Paste
Application.CutCopyMode = False
Range("M22:R22").Select
Selection.Style = "Percent"
Selection.Copy
Range("B21").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False