Hi Peoples,
I have constructed a macro to copy a column of data, paste to a new sheet and then remove duplicates. Everything worked fine until I tried to amend the code to paste just the values and not the formats. Also the remove duplicates removes the formats in the new sheet after the data finishes e.g. if original data is 50 rows and with duplicates removed becomes just 20 rows, the previous rows (21 to 50) will have their formats removed.
Code as follows:
Private Sub CommandButton3_Click()
Sheet3.Select
Range("A6", Cells(Rows.Count, "A").End(xlUp)).Copy
Sheet1.Activate
ActiveSheet.Range("A6").PasteSpecial Paste:=xlPasteValues
Application.Selection.RemoveDuplicates Columns:=1, Header:=xlNo
Range("A6", .Range("A6" & .Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
ActiveSheet.Range("A6").Select
End Sub
The macro stops at the command ".Rows.Count" in the 7th line.
Can anyone help?
Thanks
I have constructed a macro to copy a column of data, paste to a new sheet and then remove duplicates. Everything worked fine until I tried to amend the code to paste just the values and not the formats. Also the remove duplicates removes the formats in the new sheet after the data finishes e.g. if original data is 50 rows and with duplicates removed becomes just 20 rows, the previous rows (21 to 50) will have their formats removed.
Code as follows:
Private Sub CommandButton3_Click()
Sheet3.Select
Range("A6", Cells(Rows.Count, "A").End(xlUp)).Copy
Sheet1.Activate
ActiveSheet.Range("A6").PasteSpecial Paste:=xlPasteValues
Application.Selection.RemoveDuplicates Columns:=1, Header:=xlNo
Range("A6", .Range("A6" & .Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
ActiveSheet.Range("A6").Select
End Sub
The macro stops at the command ".Rows.Count" in the 7th line.
Can anyone help?
Thanks