I have taken a copy of a worksheet in my work book and want to model the figures in a certain column by a variable rate. My code is as follows.
Sub Inflate_Expense()
Dim Rate As Integer
Dim rngData As Range
get_Rate:
Rate = Application.InputBox("Enter the rate", , , , , , , 1)
Set rngData = ThisWorkbook.Worksheets("Sheet1").Range("K103:K256")
rngData = Evaluate(rngData.Address & "*Rate")
End Sub
What happens is the values in my worksheet result in #NAME?, which im guessing is because it is trying to multiply "*Rate" as a string and is not using "Rate" as the result of the input box.
I know the code works if i replace Rate with number ie:
Set rngData = ThisWorkbook.Worksheets("Sheet1").Range("K103:K256")
rngData = Evaluate(rngData.Address & "*1.02")
What I'm having difficulty with is replacing
Evaluate(rngData.Address & "*Rate")
To match the input box result.
答案 0 :(得分:0)
Sub Inflate_Expense()
Dim Rate As Variant
Dim rngData As Range
get_Rate:
Rate = Application.InputBox("Enter the rate", , , , , , , 1)
Set rngData = ThisWorkbook.Worksheets("Sheet1").Range("K103:K256")
rngData = Evaluate(rngData.Address & "*" & Rate)
End Sub