ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel formula not displaying a number (https://www.excelbanter.com/excel-programming/387928-excel-formula-not-displaying-number.html)

jtdunn

Excel formula not displaying a number
 
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


MH[_2_]

Excel formula not displaying a number
 
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

"jtdunn" wrote in message
...
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




NickHK

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

NickHK

"jtdunn" wrote in message
...
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





All times are GMT +1. The time now is 02:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com