J
jay
It fails at myTable1 = .Range(myColumn & _
'I am using 3 columns o,p,q for names,
'myTable is column O with 48 employees names used for sheet names.
'myTable1 is used
'myColumn is column P with the ranges
Dim myTable As Variant
Dim myTable1 As Variant
Dim myColumn As Variant
Dim myColumn1 As Vairant 'is column Q used for changing row for counting.
Dim iCtr As Long
Dim i As Long 'used for inside loop to copy found records to employee sheet.
Dim FoundCell As Range
With ThisWorkbook.Worksheets("Table")
myTable = .Range("o1" & _
.Cells(.Rows.Count, "O").End(xlUp).Row).Value
myColumn = .Range("p1" & _
.Cells(.Rows.Count, "P").End(xlUp).Row).Value
myColumn1 = .Range("q1:Q" & _
.Cells(.Rows.Count, "Q").End(xlUp).Row).Value
End With
With ActiveSheet.Range("a:a")
For iCtr = LBound(myTable, 1) To UBound(myTable, 1)
With ActiveSheet.Range("H:H")
'Sheets(myTable).Select
Cells.Select
' Selection.ClearContents
Sheets("Sheet1").Select
With ThisWorkbook.Worksheets("Table")
myTable1 = .Range(myColumn & _
.Cells(.Rows.Count, "mycolumn1").End(xlUp).Row).Value
End With
With ActiveSheet.Range("H:H")
For i = LBound(myTable1, 1) To UBound(myTable1, 1)
Set FoundCell1 = .Cells.Find(What:=myTable1(iCtr, 1), _
After:=.Cells(.Cells.Count), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False)
If FoundCell1 Is Nothing Then
Else
FoundCell1.EntireRow.Copy _
Destination:=Worksheets(myTable).Range("a" & iCtr)
End If
Next i
'Next iCtr
End With
'I am using 3 columns o,p,q for names,
'myTable is column O with 48 employees names used for sheet names.
'myTable1 is used
'myColumn is column P with the ranges
Dim myTable As Variant
Dim myTable1 As Variant
Dim myColumn As Variant
Dim myColumn1 As Vairant 'is column Q used for changing row for counting.
Dim iCtr As Long
Dim i As Long 'used for inside loop to copy found records to employee sheet.
Dim FoundCell As Range
With ThisWorkbook.Worksheets("Table")
myTable = .Range("o1" & _
.Cells(.Rows.Count, "O").End(xlUp).Row).Value
myColumn = .Range("p1" & _
.Cells(.Rows.Count, "P").End(xlUp).Row).Value
myColumn1 = .Range("q1:Q" & _
.Cells(.Rows.Count, "Q").End(xlUp).Row).Value
End With
With ActiveSheet.Range("a:a")
For iCtr = LBound(myTable, 1) To UBound(myTable, 1)
With ActiveSheet.Range("H:H")
'Sheets(myTable).Select
Cells.Select
' Selection.ClearContents
Sheets("Sheet1").Select
With ThisWorkbook.Worksheets("Table")
myTable1 = .Range(myColumn & _
.Cells(.Rows.Count, "mycolumn1").End(xlUp).Row).Value
End With
With ActiveSheet.Range("H:H")
For i = LBound(myTable1, 1) To UBound(myTable1, 1)
Set FoundCell1 = .Cells.Find(What:=myTable1(iCtr, 1), _
After:=.Cells(.Cells.Count), _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
MatchCase:=False)
If FoundCell1 Is Nothing Then
Else
FoundCell1.EntireRow.Copy _
Destination:=Worksheets(myTable).Range("a" & iCtr)
End If
Next i
'Next iCtr
End With