S
SITCFanTN
I'm trying to use this code to add new sheets to a workbook and copy
information from sheet 1 "All Records" to sheet titled "GESA CC" based on
"4-$" in Col A and "GESA CC" in Col B.
The issues I"m having is for some reason only 3 page are being created then
a generic Sheet 4? Not at all sure why that is happening. Then the sort,
copy and paste is not working. Any help you can provide is certainly
appreciated. Thank you.
Sub AllRecordsSortMacros()
Call AddSheets
Call CopyData
End Sub
Sub AddSheets()
Dim NewSheets As Variant
Dim i As Long
NewSheets = Array("Confirm", "GESV CC", "GESA CC", "GESA CC", "All
Matches", "All No Matches")
For i = UBound(NewSheets) To LBound(NewSheets) Step -1
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i
End Sub
Sub CopyData()
Dim rng As Range, cell As Range
Dim i As Long, sh As Worksheet
With Worksheets("All Records")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
Set sh = Worksheets("All Records")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" And _
UCase(Trim(cell.Offset( _
0, 1).Value)) = "GESA CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1
End If
Next
End Sub
information from sheet 1 "All Records" to sheet titled "GESA CC" based on
"4-$" in Col A and "GESA CC" in Col B.
The issues I"m having is for some reason only 3 page are being created then
a generic Sheet 4? Not at all sure why that is happening. Then the sort,
copy and paste is not working. Any help you can provide is certainly
appreciated. Thank you.
Sub AllRecordsSortMacros()
Call AddSheets
Call CopyData
End Sub
Sub AddSheets()
Dim NewSheets As Variant
Dim i As Long
NewSheets = Array("Confirm", "GESV CC", "GESA CC", "GESA CC", "All
Matches", "All No Matches")
For i = UBound(NewSheets) To LBound(NewSheets) Step -1
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i
End Sub
Sub CopyData()
Dim rng As Range, cell As Range
Dim i As Long, sh As Worksheet
With Worksheets("All Records")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
Set sh = Worksheets("All Records")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" And _
UCase(Trim(cell.Offset( _
0, 1).Value)) = "GESA CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1
End If
Next
End Sub