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

- - Latest reply:  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

See more 

1 reply

Posts
2566
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 19, 2019
370
-1
Thank you
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