Siddhu11011
Board Regular
- Joined
- Jun 22, 2022
- Messages
- 56
- Office Version
- 365
- Platform
- Windows
I have data in "Pivot" sheet from column A to E. I have existing multiple sheets. based on sheet name, filter out column A in "pivot" sheet; copy out put and go to respective sheet to paste the data. I have existing code but don`t know the pasting part. Please help me out
Sub Macro1()
Dim y As Range
Dim rng1 As Range
Dim last1 As Long
Dim sht1 As String
'
'specify sheet name in which the data is stored
sht1 = "Pivot"
last1 = Sheets(sht1).Cells(Rows.Count, "A").End(xlUp).Row
Set rng1 = Sheets(sht1).Range("A1:E" & last1)
For Each y In Range([AA2], Cells(Rows.Count, "AA").End(xlUp)) 'AA column contains all exhisting sheet name
With rng1
.AutoFilter
.AutoFilter Field:=1, Criteria1:=y.Value
.SpecialCells(xlCellTypeVisible).Copy
'Which code can help me to search sheet name and paste"
End With
Next y
End Sub
Sub Macro1()
Dim y As Range
Dim rng1 As Range
Dim last1 As Long
Dim sht1 As String
'
'specify sheet name in which the data is stored
sht1 = "Pivot"
last1 = Sheets(sht1).Cells(Rows.Count, "A").End(xlUp).Row
Set rng1 = Sheets(sht1).Range("A1:E" & last1)
For Each y In Range([AA2], Cells(Rows.Count, "AA").End(xlUp)) 'AA column contains all exhisting sheet name
With rng1
.AutoFilter
.AutoFilter Field:=1, Criteria1:=y.Value
.SpecialCells(xlCellTypeVisible).Copy
'Which code can help me to search sheet name and paste"
End With
Next y
End Sub