Forum Discussion

916380172248's avatar
916380172248
Copper Contributor
Aug 22, 2024

Vlookup for excel continuously add15 sheet with macro

Sub santo()
Set ws = Worksheets("Filter")
LastRow = Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row
For i = 1 To 15
    a = Array(ws.Range(a(i) & "1").Value, ws.Range(a(i) & "2").Value, ws.Range(a(i) & "3").Value, ws.Range(a(i) & "4").Value)
    Sheets.Add.Name = a(0)
    With Worksheets("Sales Data").Range("A1" & LastRow)
      .AutoFilter Field:=4, Criteria1:=Array(a(1), a(2), a(3)), Operator:=xlFilterValues
      .SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets(a(0)).Range("A1")
    End With
Next
End Sub​
 

Resources