M
MichaelDavid
Greetings! This one has me stumped. I wrote the following Procedure:
Sub TestLbName()
Dim LstRowData As Long
LstRowData = [O2]
' NOTE: The follwg straight computation (which is NOT a formula) gives the
correct result!
Cells(LstRowData + 2, "W") = Range("W" & LstRowData) ^ 2 / Range("I4")
' Whereas the following formula will not compile:
Cells(LstRowData + 2, "W").Formula = "= Range("W" & LstRowData) ^ 2 /
Range("I4")"
' and the following formula will compile but gives a #NAME error upon
execution
Cells(LstRowData + 2, "W").Formula = "= (W & LstRowData) ^ 2 / (I4)"
' And if LstRowData is, for example, 115, the following formula gives the
correct result.
Cells(LstRowData + 2, "W").Formula = "= (W115) ^ 2 / (I4)"
' Is there any way of constructing this formula for the general case
(LstRowData not necessarily 115)? The only solution I can presently come up
with is a monster Select Case
End Sub
--
May you have a most blessed day!
Sincerely,
Michael Fitzpatrick
Sub TestLbName()
Dim LstRowData As Long
LstRowData = [O2]
' NOTE: The follwg straight computation (which is NOT a formula) gives the
correct result!
Cells(LstRowData + 2, "W") = Range("W" & LstRowData) ^ 2 / Range("I4")
' Whereas the following formula will not compile:
Cells(LstRowData + 2, "W").Formula = "= Range("W" & LstRowData) ^ 2 /
Range("I4")"
' and the following formula will compile but gives a #NAME error upon
execution
Cells(LstRowData + 2, "W").Formula = "= (W & LstRowData) ^ 2 / (I4)"
' And if LstRowData is, for example, 115, the following formula gives the
correct result.
Cells(LstRowData + 2, "W").Formula = "= (W115) ^ 2 / (I4)"
' Is there any way of constructing this formula for the general case
(LstRowData not necessarily 115)? The only solution I can presently come up
with is a monster Select Case
End Sub
--
May you have a most blessed day!
Sincerely,
Michael Fitzpatrick