Macro to insert data to changing cells

Solved/Closed
Kasper - Oct 4, 2011 at 09:52 AM
 Kasper - Oct 5, 2011 at 10:05 AM
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 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Oct 4, 2011 at 10:10 AM
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
-1
Thank you very much. It solved the problem in an easy way.

Regards,
Kasper
0