1
Thanks

A few words of thanks would be greatly appreciated.

Excel - A Macro to insert data in specific cells



Issue


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.

Solution


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

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



Thanks to TrowaD for this tip.
1
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by jak58.

This document, titled "Excel - A Macro to insert data in specific cells," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments