Can somebody please help!!
I have set this macro up on a button, so whenever it is clicked a mastersheet is populated from the data in sheets "test1" and "test2".
What i ideally want is everytime its clicked it replaces the old data and replaces. (to take into consideration of any changes) however at the moment it is adding in the data again. please please can someone help.
Thanks in advance
R
I have set this macro up on a button, so whenever it is clicked a mastersheet is populated from the data in sheets "test1" and "test2".
What i ideally want is everytime its clicked it replaces the old data and replaces. (to take into consideration of any changes) however at the moment it is adding in the data again. please please can someone help.
Thanks in advance
R
Code:
Private Sub CommandButton1_Click()
Dim Sheet As Worksheet
For Each Sheet In Me.Parent.Sheets
If Sheet.Name = "test1" Or _
Sheet.Name = "test2" Then
If Sheet.Cells(Rows.Count, 1).End(xlUp).Row <> 1 Then
Sheet.Range(Sheet.Cells(2, 1), Sheet.Cells(Sheet.Cells(Rows.Count, 1).End(xlUp).Row, 10)).Copy Destination:=Me.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
End If
Else
Me.Range(Cells(20, 20), Cells(Rows.Count, 10)).Clear
End If
Next Sheet
End Sub