A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi,
try this code
[Update-2]
Sub Append_Data_ValuesFormats() '<< START VBA
' ## 22-06-2023 ##
Const colStart$ = "A" 'First column in both sheets / change as needed
Const colEnd$ = "Y" 'Last column in both sheets / change as needed
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets("Sheet1") '<< source sheet name / change as needed
Set ws2 = Sheets("Sheet2") '<< target sheet name / change as needed
Dim rng As Range
Dim N1, N2, c, v, x
N1 = 5 '<< headers in row5, in source sht / change as needed
N2 = 5 '<< headers in row5, in target sht / change as needed
Dim L1, L2
L1 = ws1.Cells(Rows.Count, colStart).End(xlUp).Row
L2 = ws2.Cells(Rows.Count, colStart).End(xlUp).Row
Application.ScreenUpdating = False
ws1.Range(ws1.Cells(N1 + 1, colStart), ws1.Cells(L1, colEnd)).SpecialCells(xlCellTypeVisible).Copy
ws2.Cells(L2 + 1, colStart).PasteSpecial xlFormats
ws2.Cells(L2 + 1, colStart).PasteSpecial xlValues
Application.CutCopyMode = False
L2 = ws2.Cells(Rows.Count, colStart).End(xlUp).Row
c = ws2.Range(ws2.Cells(1, colStart), ws2.Cells(1, colEnd)).Columns.Count
ReDim v(0 To c - 1)
For x = 0 To c - 1
v(x) = x + 1
Next x
Set rng = ws2.Range(ws2.Cells(N2, colStart), ws2.Cells(L2, colEnd))
rng.RemoveDuplicates Columns:=(v), Header:=xlYes
Application.ScreenUpdating = True
End Sub'<< END VBA
======================================
sample
- before run the code
data in source sheet
data in target sht
- after run the code
result in target sht