Excel - Copy data into next empty cell in new sheet

December 2016


I am trying to make a 2 sheet workbook which has the input details in Sheet1
A1 and this is changed weekly but the info in this cell should then be
inserted into the first blank cell in Column A in Sheet 2.

I have tried this code (below) but it doesn't seem to work and maybe I am
doing something wrong. Could someone let me know if this code should work
for this purpose or is there another code I could try?

Code used at present:

Sub copytonextsheet() 
With Sheets("Sheet2") 
n = .Cells(Rows.Count, "A").End(xlUp).Row + 1 
.Cells(n, "A").Resize(, 4).Value = _ 
Cells(1, "A").Resize(, 4).Value 
End With 
End Sub 


Try this:
Sub CopyRowsWithNumbersInG() 
Dim X As Long 
Dim LastRow As Long 
Dim Source As Worksheet 
Dim Destination As Worksheet 
Dim RowsWithNumbers As Range 
Set Source = Worksheets("name") 
Set Destination = Worksheets("name") 
With Source 
LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row 
For X = 2 To LastRow 
If IsNumeric(.Cells(X, "E").Value) And .Cells(X, "E").Value <> "" Then 
If RowsWithNumbers Is Nothing Then 
Set RowsWithNumbers = .Cells(X, "E") 
Set RowsWithNumbers = Union(RowsWithNumbers, .Cells(X, "E")) 
End If 
End If 
If Not RowsWithNumbers Is Nothing Then 
RowsWithNumbers.EntireRow.Copy Destination.Range("A4") 
End If 
End With 
MsgBox "Data has been updated !!", vbExclamation + vbInformation, "Company Name" 
End Sub

Thanks to Kioskea_1 for this tip.

Related :

This document entitled « Excel - Copy data into next empty cell in new sheet  » 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.