robertsfd
Technical User
- Apr 18, 2003
- 40
I have a spreadsheet with several columns. Half the columns are formulas based on the other half of the columns that contain values input by the user. For the user input cells, I have a macro that requests these input values with an InputBox and puts them in the cell, moves a few columns over, requests another input and places it in the cell, and so on. The next time the macro runs, it goes to the next new row and does the same thing.
The first time I run the macro (i.e., the first time the user inputs any information), it runs and asks for the first input and puts it in the cell but goes no further. If I run it again, it moves down a row as it should and asks for the first input, inputs the value supplied, and stops. The third time on, everything works well - it goes through the whole code and works as it should.
Any ideas where I have gone wrong? Why it works the third time on but not the first two? Thanks in advance, Doug
The first time I run the macro (i.e., the first time the user inputs any information), it runs and asks for the first input and puts it in the cell but goes no further. If I run it again, it moves down a row as it should and asks for the first input, inputs the value supplied, and stops. The third time on, everything works well - it goes through the whole code and works as it should.
Any ideas where I have gone wrong? Why it works the third time on but not the first two? Thanks in advance, Doug
Code:
Sub InputDetail()
'move to beginning of worksheet values
Range("B8").Select
'go to end of range
Selection.End(xlDown).Select
'move down one more row
ActiveCell.Offset(rowOffset:=1).Activate
'get user value and input to current cell
ActiveCell.FormulaR1C1 = InputBox("Input your fill date")
'move to right four columns
ActiveCell.Offset(columnOffset:=4).Activate
'get user value and input to current cell
ActiveCell.FormulaR1C1 = InputBox("Input your ending mileage")
'move to right four columns
ActiveCell.Offset(columnOffset:=4).Activate
'get user value and input to current cell
ActiveCell.FormulaR1C1 = InputBox("Input the number of gallons bought")
'move to right four columns
ActiveCell.Offset(columnOffset:=4).Activate
'get user value and input to current cell
ActiveCell.FormulaR1C1 = InputBox("Input the price per gallon you bought")
'display ending message
MsgBox ("Your 'CELL REF' was 'CELL REF'")
'move to beginning of worksheet
Range("B2").Select
'save worksheet
ActiveWorkbook.Save
End Sub