Sub Delete_rows()
Application.ScreenUpdating = False
'This Is the column that will always contain a value
YourColumn = 7 'i.e. column B - C =3, D = 4 etc
dlCnt = 0
For i = 2 To 10000
If Cells(i, YourColumn).Value = "Payer Short" Then
Rows(i).Delete
i = i - 1
dlCnt = dlCnt + 1
If dlCnt > 20000 Then Exit Sub
ElseIf Cells(i, YourColumn).Value = "" Then
Rows(i).Delete
i = i - 1
dlCnt = dlCnt + 1
If dlCnt > 20000 Then Exit Sub
End If
Next
Application.ScreenUpdating = True
End Sub
Sub AddPayerSheets()
'JBeaucaire(12/10/2009)
'Based on column G, data is filtered to individual sheets
'Creates sheets and sorts alphabetically in workbook
Dim LR As Long, i As Long, MyArr
Dim MyCount As Long, ws As Worksheet
Application.ScreenUpdating = False
Set ws = Sheets("Periodic Decisions by Rule")
ws.Activate
Columns("G:G").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AH1"), Unique:=True
Columns("AH:AH").Sort Key1:=Range("AH2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
MyArr = Application.WorksheetFunction.Transpose(Range("AH2:AH" & Rows.Count).SpecialCells(xlCellTypeConstants))
Range("AH:AH").Clear
Range("A1:AF1").AutoFilter
For i = 1 To UBound(MyArr)
Range("A1:AF1").AutoFilter Field:=7, Criteria1:=MyArr(i)
LR = Range("G" & Rows.Count).End(xlUp).Row
If LR > 1 Then
If Not Evaluate("=ISREF('" & MyArr(i) & "'!A1)") Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = MyArr(i)
Else
Sheets(MyArr(i)).Move After:=Sheets(Sheets.Count)
Sheets(MyArr(i)).Cells.Clear
End If
ws.Activate
Range("A1:AF" & LR).Copy Sheets(MyArr(i)).Range("A1")
Range("A1:AF1").AutoFilter Field:=7
MyCount = MyCount + Sheets(MyArr(i)).Range("G" & Rows.Count).End(xlUp).Row - 1
Sheets(MyArr(i)).Columns.AutoFit
Sheets(MyArr(i)).Rows.RowHeight = 48
End If
Next i
ActiveSheet.AutoFilterMode = False
LR = Range("G" & Rows.Count).End(xlUp).Row - 1
MsgBox "Rows with data: " & LR & vbLf & "Rows copied to other sheets: " & MyCount & vbLf & "Hope they match!!"
Application.ScreenUpdating = True
End Sub
Sub MergeRows()
'JBeaucaire (12/9/2009)
'Compares columns A,B,C,D,E,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF and if same, merges rows
'Concatenates columns I and U if different/unique
Dim LR As Long, i As Long
Application.ScreenUpdating = False
LR = ActiveSheet.Range("G" & Rows.Count).End(xlUp).Row
i = 2
'Sort data so like items are adjacent
Range("A1:AF6000").Sort Key1:=Range("H1"), Order1:=xlAscending, Key2:=Range("L1"), Order2:=xlAscending, Key3:=Range("I1"), Order3:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'Insert key column to determine matches
Range("AJ2:AJ" & LR).FormulaR1C1 = _
"=RC1&""-""&RC2&""-""&RC3&""-""&RC4&""-""&RC5&""-""&RC6&""-""&RC7&""-""&RC8&""-""&RC10&""-""&RC11&""-""&RC12&""-""&RC13&""-""&RC14&""-""&RC15&""-""&RC16&""-""&RC17&""-""&RC18&""-""&RC19&""-""&RC20&""-""&RC22&""-""&RC23&""-""&RC24&""-""&RC25&""-""&RC26&""-""&RC27&""-""&RC28&""-""&RC29&""-""&RC30&""-""&RC31&""-""&RC32"
'Merge like rows
Do
If Range("AJ" & i) = Range("AJ" & i + 1) Then
If InStr(Range("I" & i), Range("I" & i + 1)) = 0 Then _
Range("I" & i) = Range("I" & i) & "," & Range("I" & i + 1)
If InStr(Range("U" & i), Range("U" & i + 1)) = 0 Then _
Range("U" & i) = Range("U" & i) & "," & Range("U" & i + 1)
Rows(i + 1).Delete xlShiftUp
Else
i = i + 1
If Cells(i, "G") = "" Then Exit Do
End If
Loop
'Remove key column
Columns("AJ:AJ").ClearContents
Application.ScreenUpdating = True
End Sub