9tanstaafl9
Well-known Member
- Joined
- Mar 23, 2008
- Messages
- 535
Hi. I've been out of practice with VBA for a few months and I can't remember how to do this...
My code searches through all the used cells in column D to find a blank cell (which only occurs on subtotal rows -- the actual subtotal descriptions are in column B which is hidden) . Then I use VBA to insert the description I want to show in this blank cell in col D.
I need the code to insert a formula that looks at the cell one row above and two rows to the left, but unfortunately, I have no idea what that cell will be at the time the code is inserting the formula. Is there a way to do this?
Here's what the formula would look like if I just typed it into field D196 in Excel:
Here's what I have now (looking for the ????:
Please help, I've been working on this for hours
My code searches through all the used cells in column D to find a blank cell (which only occurs on subtotal rows -- the actual subtotal descriptions are in column B which is hidden) . Then I use VBA to insert the description I want to show in this blank cell in col D.
I need the code to insert a formula that looks at the cell one row above and two rows to the left, but unfortunately, I have no idea what that cell will be at the time the code is inserting the formula. Is there a way to do this?
Here's what the formula would look like if I just typed it into field D196 in Excel:
Code:
=VLOOKUP(B195,PhaseNameRange,2)
Here's what I have now (looking for the ????:
Code:
rng = Range(Range("b17"), Range("b" & Rows.Count).End(xlUp)).Rows.Count
Dim FormatVar As Range
Set FormatVar = Range("d17")
For i = 1 To rng
If IsEmpty(FormatVar) Then
FormatVar.Value = "Phase " & FormatVar.Offset(0, -2) & " - " & ????
FormatVar.HorizontalAlignment = xlRight
Set FormatVar = FormatVar.Offset(1, 0)
Else
Set FormatVar = FormatVar.Offset(1, 0)
End If
Next i
Please help, I've been working on this for hours
