Excel - Copy data into next empty cell in new sheet

May 2017




Issue


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 

Solution


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") 
Else 
Set RowsWithNumbers = Union(RowsWithNumbers, .Cells(X, "E")) 
End If 
End If 
Next 
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


Published by aakai1056. Latest update on March 1, 2012 at 10:14 AM by aakai1056.
This document, titled "Excel - Copy data into next empty cell in new sheet ," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).