Hi all-
I'm trying to run a simple loop and I keep getting "compile error: Else without if" that doesn't make sense to me.
Basically I'm checking a range for formulas and if there is a formula, I'll skip that cell. If the cell is blank, I'll enter a formula in an adjacent cell. Any help from more experienced users is appreciated. Here's what I'm working with:
Code[
Sub hedgeme()
Dim MyCell As Range, MyRange As Range
Set MyRange = Range("S13:S20")
For Each MyCell In MyRange
If MyCell.HasFormula Then MyCell.Offset(1, 0).Select
Else MyCell.Offset(0, 1).Value = "=IF(RC[-1]<-R2C20,RC[-9]-RC[-7],IF(RC[- -1]>R2C20,+RC[-9]-RC[-7],0))"
End If
Next MyCell
End Sub
]Code
I'm trying to run a simple loop and I keep getting "compile error: Else without if" that doesn't make sense to me.
Basically I'm checking a range for formulas and if there is a formula, I'll skip that cell. If the cell is blank, I'll enter a formula in an adjacent cell. Any help from more experienced users is appreciated. Here's what I'm working with:
Code[
Sub hedgeme()
Dim MyCell As Range, MyRange As Range
Set MyRange = Range("S13:S20")
For Each MyCell In MyRange
If MyCell.HasFormula Then MyCell.Offset(1, 0).Select
Else MyCell.Offset(0, 1).Value = "=IF(RC[-1]<-R2C20,RC[-9]-RC[-7],IF(RC[- -1]>R2C20,+RC[-9]-RC[-7],0))"
End If
Next MyCell
End Sub
]Code