Input box cell addresses are hard coded. Is there a way to make them change when going to new row?

Royzer

New Member
Joined
Jun 22, 2010
Messages
48
Hi. I need my Input Box data to fill in on one row and then the next time they run fill in the next row, etc. My problem is that the starting ranges are locked in, so even though it goes to the first cell of the next row after enter, the input data after the first cell go right back to the original cell. Are there variables I can use in the place of ("B2"), ("C2"), etc? Thank you.



Code:
Sub TestMacro()
Dim i As Integer
    Range("a1").Select
    Range(Selection, Selection.End(xlDown)).Select
    i = Selection.Rows.Count
    Cells(i + 1, 1).Select
    ActiveCell.FormulaR1C1 = InputBox("Date")
    Range("B2").Select
    ActiveCell.FormulaR1C1 = InputBox("Project #")
    Range("C2").Select
    ActiveCell.FormulaR1C1 = InputBox("Fault")
    Range("D2").Select
    ActiveCell.FormulaR1C1 = InputBox("Problem")
    Range("E2").Select
    ActiveCell.FormulaR1C1 = InputBox("Solution")
    ActiveCell.Offset(1, 0).Select
    Range(ActiveCell.EntireRow.Address)(1, 1).Select
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try
Code:
Sub TestMacro()
Dim i As Integer, lr As Long
    lr = Cells(Rows.Count, "A").End(xlUp).Row + 1
    Cells(lr, 1).Value = InputBox("Date")
    Cells(lr, 2).Value = InputBox("Project #")
    Cells(lr, 3).Value = InputBox("Fault")
    Cells(lr, 4).Value = InputBox("Problem")
    Cells(lr, 5).Value = InputBox("Solution")
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,276
Messages
6,171,140
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top