Hi ,
I am having one company data file, in that file we have to filter one department name and copy that data into another sheet, i tried but its not working with below code, please help
I am having one company data file, in that file we have to filter one department name and copy that data into another sheet, i tried but its not working with below code, please help
VBA Code:
Sub RMG2()
Dim PLfilter As String
Set Macro = Workbooks("RMG_Macro.xlsm")
Set Macrows = Macro.Sheets("Sheet2")
Set Macrohome = Macro.Sheets("HOME")
Set RMGSheet = Workbooks("RMG Base report 05 May 2022.xlsx")
' Set RMGSheet = Workbooks.Open(Filename:=(Macrohome.Range("F4").Value))
Set RMGSheetws = RMGSheet.Sheets("RMG Asso Base Data Report_Deliv")
Macrows.Rows("2:" & Rows.Count).Delete
a = RMGSheetws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To a
If RMGSheetws.Range("BK" & i).Value = "TAT" Then
RMG2_1 RMGSheetws:=RMGSheetws, i:=i, Macrows:=Macrows
End If
Next i
End Sub
Public Sub RMG2_1(ByVal i As Long, ByVal RMGSheetws As Worksheet, ByVal Macrows As Worksheet)
With RMGSheetws
For Each Condition In .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).SpecialCells(xlCellTypeVisible)
If RMGSheetws.Range("DJ" & i).Value = "Satya" Then
Macrows.Range("A" & i).Value = Condition.Offset(0, 0).Value
Macrows.Range("B" & i).Value = Condition.Offset(0, 1).Value
Exit For
ElseIf RMGSheetws.Range("DJ" & i).Value = "Satya 12" Then
Macrows.Range("A" & i).Value = Condition.Offset(0, 0).Value
Macrows.Range("B" & i).Value = Condition.Offset(0, 4).Value
Exit For
Else
Exit Sub
End If
Next
End With
End Sub