Excel - Paste macro to variable row address

September 2016


Issue

I currently have a worksheet with a database in it. I can call up the data using the vlookup function. I need a macro that will allow to replace some data in the data base. I know that what row number the data occurs in and the columns remain fixed. So i need to perform a command that will do the following" cell A1=the row number the data is on i.e. row 112. so i need to paste to cell G (a1) or g112 from cell A3. cell A1 changes with each data point so I'm not always copying to G112, the next time it can be G650.

Solution

Try this:
Sheets("Database").range(sheets("sheet1").range("A1").value).value=sheets("sheet1").range("A3").value 


for a button_click event

Note

Thanks to Excelguru for this tip on the forum.

Related :

This document entitled « Excel - Paste macro to variable row address » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.