Welcome. I have this code to filter worksheet 1 and copy certain columns to the target columns on worksheet 2. It works very well for me. The only drawback is that it copies formats. What I want is
Editing it, for example, makes it possible to copy values only without formatting, whether fonts or formulas.
Editing it, for example, makes it possible to copy values only without formatting, whether fonts or formulas.
VBA Code:
Sub test()
Dim WS As Worksheet: Set WS = Sheets("Sheet1")
Dim r As Worksheet: Set r = Worksheets("Sheet2")
Sup = MsgBox("Copy data", _
vbCritical + vbYesNo, "Confirmation")
If Sup = vbYes Then
Application.ScreenUpdating = False
With WS
If .AutoFilterMode Then .AutoFilterMode = False
With WS.Range("A1:J1")
.AutoFilter 3, "Paris"
lr = WS.Columns("A:G").Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set Rng = WS.Range("A" & lr & ":G" & lr).SpecialCells(xlCellTypeVisible)
If WorksheetFunction.Subtotal(3, WS.Columns(3)) > 1 Then
r.Range("A2:G" & r.Rows.Count).ClearContents
With Rng
rngA = split("A,B,C,D,E,F,G", ",")
rngB = split("B,A,E,C,D,F,G", ",")
For i = LBound(rngA) To UBound(rngA)
WS.Range(rngA(i) & "2:" & rngA(i) & lr).Copy r.Range(rngB(i) & "2")
Next i
End With
End If
.AutoFilter
End With
End With
End If
Application.ScreenUpdating = True
End Sub