Excel formula not displaying a number

J

jtdunn

Hi
I need some some with this macro formula. In excel, the formula is
displayed as text and I want it to be a number. There are numbers in the
iRow of M, F and N.
The problem is the scale factor, I think. I'm tried to change Scale Factor
to a number and it still doesn't work. Any suggestions?

Dim AlphaT As Long
Dim ScaleFactor As String
Dim AlphaForm As String

If (ws.Cells(iRow, 15).Value = ".1 Scale") Then ScaleFactor = "0.1"

If ((ws.Cells(iRow, 11).Value = "XYZ"))Then
AlphaT = Abs((ws.Cells(iRow, 13).Value * ws.Cells(iRow, 6).Value) +
(ws.Cells(iRow, 14).Value * ScaleFactor))
AlphaForm = "=ABS((M" & iRow & " * F" & iRow & ")+(N" & iRow & " *" &
ScaleFactor & "))"
End If

ws.Cells(iRow, 17).Value = AlphaT
ws.Cells(iRow, 17).Formula = AlphaForm
 
M

MH

What do you want the ScaleFactor to be if the following test is false?
If (ws.Cells(iRow, 15).Value = ".1 Scale") Then ScaleFactor = "0.1"

You might consider doing the following:
ScaleFactor = "1"
If (ws.Cells(iRow, 15).Value = ".1 Scale") Then ScaleFactor = "0.1"

MH
 
N

NickHK

If the actual string always starts with a numeric value, you can use Val.
?val(".1 Scale")
0.1

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top