Hi
I am trying to create a macro to copy data from one sheet to another
The data is not copying across
Below is my code, the final row appears to be 0
Appreciate any thoughts
Thanks
kind Regards
ken
I am trying to create a macro to copy data from one sheet to another
The data is not copying across
Below is my code, the final row appears to be 0
Appreciate any thoughts
Thanks
kind Regards
ken
Code:
Sub Macro1()
'
' Macro1 Macro : Extract data to another Sheet
'
Dim datasheet As Worksheet
Dim reportsheet As Worksheet
Dim emailname As String
Dim finalrow As Integer
Dim i As Integer
' set variables
Set datasheet = Sheet2
Set reportsheet = Sheet3
emailname = reportsheet.Range("C2").Value
' clear old data
reportsheet.Range("A3:L1000").ClearContents
'gotodata sheet and starts earching and copying
datasheet.Select
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
' loop
For i = 2 To finalrow
If Cells(i, 2) = emailname Then
Range(Cells(i, 1), Cells(1, 12)).Copy
reportsheet.Select
Range("A1000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
datasheet.Select
End If
Next i
reportsheet.Select
Range("A2").Select
MsgBox "Data Copied"
'
End Sub
Last edited by a moderator: