How to copy a Macro into a blank cell

How to copy a Macro into a blank cell

In this article we will show you an example of a Macro that can copy data in the next blank cell. Using this example you should then be able to apply the solution to a specific problem that you have.


If you have two sheets in a workbook: Sheet1 is for summary and Sheet2 is for the raw data and you need to update/insert/copy data in Sheet2 to Sheet1. Below is the incorrect sample macro code:

Sub Summarize()   
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _   
False, Transpose:=False   
End Sub

This code will work, but everytime you change data in Sheet2 the Sheet1 will only replace its data. But what you are probably looking for is that everytime you change data in Sheet2, it is also added (append) in Sheet1.


You need to know the last row used. In this case Range("B283"). Select finds the last used cell in column B and then select one cell below it:

lMaxRows = Cells(Rows.Count, "B").End(xlUp).Row   
Range("B" & lMaxRows +1).select
Need more help with Excel? Check out our forum!