Macro to insert data to changing cells [Solved/Closed]

Report
-
 Kasper -
Hello,

I'm trying to write a macro in excel for inserting input text to a specified cell. I have already an InputBox specifying the text to be put in and an inputbox specifying which row to insert the data. The data always needs to be inserted in the same column.

For instance:

First i would like to insert the text, Budget, into cell B5. Afterwards i need to insert the text, Report, into cell B11 (in both cases the rows 5 and 11 are newly inserted. Thats why i use the Inputbox)

So i need some code on how to select these different cells based on the inputboxes.

Regards,
Kasper

1 reply

Posts
2621
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
May 28, 2020
420
Hi Kasper,

Try this code:
Sub test()
iText = InputBox("What text?")
iRow = InputBox("Which row?")

Cells(iRow, 2).Value = iText
End Sub

Best regards,
Trowa
Thank you very much. It solved the problem in an easy way.

Regards,
Kasper