Thread: Code Help
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Code Help

hi
might as well add my 2 cents worth.
in your original code, you have the variable Amt inside the double quotes
leading VB to assume that you ment to multiply by Amt literally and not the
variable entered into the input box. i move the variable amt outside the
double quotes.
also may several other adjustments.
Dim rng As Range
Dim lastrow As Long
Dim cell As Range
Dim Amt As Double
Amt = InputBox("By What % (As Decimal)")
Amt = Amt + 1
Set rng = Range("f16:f51")
For Each cell In rng
cell.FormulaR1C1 = "=RC[-1]*" & Amt
Next cell

"Ronbo" wrote:

I have the following code that I need to take a range (f16..f51) and
increase/decrease it by a user input value i.e. f16=e16*(1+user input)

Option Explicit
Dim rng As Range
Dim lastrow As Long
Dim cell As Range
Dim Amt As Double

Sub Test()

Amt = InputBox("By What % (As Decimal)")

Set rng = Range("f16:f51")
For Each cell In rng
cell.Value = (cell.FormulaR1C1 = "=RC[-1]*(1+Amt),")


I get "FALSE" in each cell. What am I doing wrong?

Ronbo