I was able to get help on this forum not to long ago on a solution that worked beautifully. However, I have tried to augment the number of routines.
Essentially, what I am trying to do is run a series of sort & copy/paste to another sheet.
The sorts are all well defined, but the copy/paste only works on the one sort and not all.
This is a working sort code:
This is the working copy/paste code that I obtained from this forum:
What I have been doing is running a sort like the below directly followed by "Sub EncID_IP" without any success with the copy/paste method:
Here is one of the sorts:
Below is how I envisioned using these all stringed together:
Any help would be appreciated.
Essentially, what I am trying to do is run a series of sort & copy/paste to another sheet.
The sorts are all well defined, but the copy/paste only works on the one sort and not all.
This is a working sort code:
Code:
Sub Sort_IP()
'
' Sort_IP Macro
'
'
Sheets("IP Breakout").Select
Columns("E:E").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("IP Breakout").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("IP Breakout").Sort.SortFields.Add Key:=Range("E1") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("IP Breakout").Sort
.SetRange Range("A2:M984225")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
This is the working copy/paste code that I obtained from this forum:
Code:
Sub EncID_IP()
'.:: Extract EncID
'
Dim lRow As Long ' East to West
Dim bCount As Byte '1,2,3
Dim sServiceHit As String 'Service used to find EncID
Dim rRange As Range, rCell As Range 'What am I cycling through?
Dim ws As Worksheet 'Canvas
Sheets("IP Breakout").Select
Set ws = Sheets("Results IP") 'dumping ground
ws.Range("A1") = "EncID" 'extract data
Set rRange = Range("A2", Range("A" & Rows.Count).End(xlUp)) 'Create a dynamic range to search
lRow = 2 ' go to 2 deep
For Each rCell In rRange 'look at every cell in the dynamic range
If sServiceHit <> rCell.Offset(, 4) Then
sServiceHit = rCell.Offset(, 4)
bCount = 0
End If
If bCount < 2 Then ' if X < 2
ws.Cells(lRow, "A") = rCell 'Canvas cell A + X
bCount = bCount + 1 'Add to my count by 1
lRow = lRow + 1 ' Add to my row by 1
End If
Next rCell
End Sub
What I have been doing is running a sort like the below directly followed by "Sub EncID_IP" without any success with the copy/paste method:
Here is one of the sorts:
Code:
Sub Sort_Var1High_IP()
'
' Sort_Var1High_IP Macro
'
'
Sheets("IP Breakout").Select
Range("C1").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("IP Breakout").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("IP Breakout").Sort.SortFields.Add Key:=Range( _
"E2:E500000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("IP Breakout").Sort.SortFields.Add Key:=Range( _
"N2:N500000"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("IP Breakout").Sort
.SetRange Range("A1:P500000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Below is how I envisioned using these all stringed together:
Code:
Sub Generate()
Dim Start_Time, end_time
Start_Time = Now() ' start the clock
Application.ScreenUpdating = False
Application.StatusBar = "Processing 1 of 13: IP Breakout..."
Call UnhideAll
Application.StatusBar = "Processing 2 of 13: IP Breakout..."
Call IP_Pick
Application.StatusBar = "Processing 3 of 13: IP High-Count Services Hit..."
Call Sort_IP
Call EncID_IP
Application.StatusBar = "Processing 4 of 13: IP Base v. Expected Comparsion..."
Call Sort_Var1High_IP
Call EncID_IP
Call Sort_Var1Low_IP
Call EncID_IP
Application.StatusBar = "Processing 5 of 13: IP Base v. Cash Comparison..."
Call Sort_Var2High_IP
Call EncID_IP
Call Sort_Var2Low_IP
Call EncID_IP
Application.StatusBar = "Processing 6 of 13: IP Expected v. Cash Comparison..."
Call Sort_Var3High_IP
Call EncID_IP
Call Sort_Var3Low_IP
Call EncID_IP
Application.StatusBar = "Processing 7 of 13: OP Breakout..."
Call OP_Pick
Application.StatusBar = "Processing 8 of 13: OP High-Count Services Hit..."
Call Sort_OP
Call EncID_OP
Application.StatusBar = "Processing 9 of 13: OP Base v. Expected Comparsion..."
Call Sort_Var1High_OP
Call EncID_OP
Call Sort_Var1Low_OP
Call EncID_OP
Application.StatusBar = "Processing 10 of 13: OP Base v. Cash Comparison..."
Call Sort_Var2High_OP
Call EncID_OP
Call Sort_Var2Low_OP
Call EncID_OP
Application.StatusBar = "Processing 11 of 13: OP Expected v. Cash Comparison..."
Call Sort_Var3High_OP
Call EncID_OP
Call Sort_Var3Low_OP
Call EncID_OP
Application.StatusBar = "Processing 12 of 13: Removing Duplicates..."
Call Unique_OP
Call Unique_IP
Application.StatusBar = "Processing 13 of 13: Buildinng ADS Criteria..."
Call HideAll
Application.StatusBar = ""
Sheets("ADS Criteria").Select 'Land me at the end
Range("J2").Select
Application.ScreenUpdating = True
end_time = Now() 'stop
MsgBox "EAS Generator processed entire population in " & DateDiff("S", Start_Time, end_time) & " seconds."
End Sub
Any help would be appreciated.