0
Thanks

A few words of thanks would be greatly appreciated.

Excel - Copy data into next empty cell in new sheet




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.
0
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.
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).

0 Comments