Re: Receiving error codes with using user form to rearrange and remove columns
Guess you cant help.
Re: Receiving error codes with using user form to rearrange and remove columns
Guess you cant help.
Re: Receiving error codes with using user form to rearrange and remove columns
Here is a better representation of it... I feel like it shouldnt be THAT difficult if you know what you're doing and have used these each on an individual basis ... its just that I haven't done all of these via userform before
Re: Receiving error codes with using user form to rearrange and remove columns
just thought about it and I guess it would actually be 4 tiers... first tier would be a list of all of the columns (not sure if I mentioned this but it needs to be dynamic
in the sense the number of columns will vary.. and the date fields, etc. would also vary from column to column depending on the data in the spreadsheet...
Tier1 - All Columns (Individual Selections to choose how to filter)
Add / Remove Box Add/Remove Add/Remove
Tier2 - Select which filter items (duplicates) you want (Checkbox) / Date1 (Text Field) Date2 (Text Field) / Blank or Not Blank (Select which)
Tier 3 Add Add Add
Table would be filtered in the background at this point and the selections would be added here
Tier 4 Choose the order of the columns (Move up, down?)
Remove any columns you do not want
Send to Spreadsheet Select "Go" and create new worksheet with the
then clear original table filtered / arrange / visible cells data
filters
Re: Receiving error codes with using user form to rearrange and remove columns
I guess the tier 3 would just be just moving all visible cells from 1 column, one at a time, in the order of the selection..
Re: Receiving error codes with using user form to rearrange and remove columns
Ideally yes, I would want an option to filter the data but if no filters are selected, then it would move everything.
The filters would be
1.) - Duplicate text one column (so, just the same if you were to filter a table) --- i was thinking this would be a check box field
2.) - date range for the columns that only contain dates (there are never any columns that have a mix of dates and text) --- was thinking this would be 2 fields for the date range
3.) - Blank or not Blank
So, my original plan was to have
1.) list of all fields (tier 1) --- you would select which ones you wanted to move and then in "tier 2" of the report you would have 3 separate choices of where to add the item from tier 1. Those choices would be the 3 filtering options I listed above
-
2.) 3 separate areas to add those fields to, with 3 separate add/remove areas because of the 3 different filter options (this would be what i am referencing as tier 2)
- from there you would filter accordingly and again select "add" which would move the data to the final area prior to selecting "Go" or something where it creates the new sheet. (I would imagine all of the filtering could be done in the background as the user is making their choices.. then the "Go" button would just be moving all visible cells...
3.) tier 3 would be the final selection... which is the option to remove columns or rearrange the column order
I am not even sure if this is doable but it made sense to me because of like I said, the filtering as you go in the background..
Re: Receiving error codes with using user form to rearrange and remove columns
***Note*** I am not using the sub named "Rando" I was trying to use some code so that it would by dynamic instead of listing the "LB1.AddItem (Sheet1.Range("a1"))" , b1, c1, etc code.... but also couldn't get that working...
Re: Receiving error codes with using user form to rearrange and remove columns
Well, my original thought was to also have the functionality to both filter out criteria as well as rearrange/remove columns (then export to sheet2) but I couldnt figure out how to do both at once... so i guess my question is do you know how to do that? And if not, what do I need to change to just rearrange/move only the selected columns? Below is the full code for that userform... (minus the trigger in the module..)
Private Sub ColumnArrange_Click()On Error Resume Next
Sheet1.Unprotect
Dim ws As Worksheet
Dim ws2 As Worksheet
Set ws = Sheets("Sheet1")
Dim rng As Range
Set rng = ws.Range("$a1").CurrentRegion
Sheets.Add.Name = "Sheet2"
Set ws2 = Sheets("Sheet2")
ws.ListObjects("Data").Unlist
If LB2.ListCount = 0 Then
MsgBox "You did not choose a filter field"
Exit Sub
End If
ProgressDlg.Show
For basliklar = 0 To LB2.ListCount - 1
baslangic_satiri = 2
ws2.Cells(baslangic_satiri - 1, basliklar + 1) = LB2.List(basliklar, 0)
ws1.Cells(1, 1).CurrentRegion.Select.AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=rng.Select, _
CopyToRange:=ws2.Cells(baslangic_satiri - 1, basliklar + 1), _
Unique:=False
Next
ws2.Columns.EntireColumn.AutoFit
CMD6.Enabled = True
End Sub
Private Sub CMD2_Click()
Unload Me
End Sub
Private Sub CMD4_Click()
If LB2.Text = "" Then
MsgBox "Please make a selection"
End If
If LB2.ListIndex > -1 Then
LB1.AddItem LB2.Value
LB2.RemoveItem (LB2.ListIndex)
End If
End Sub
Private Sub CMD5_Click()
If LB1.Text = "" Then
MsgBox "Please make a selection"
End If
If LB1.ListIndex > -1 Then
LB2.AddItem LB1.Value
LB1.RemoveItem (LB1.ListIndex)
End If
End Sub
Private Sub CMD6_Click()
Sheets("Sheet2").Select
Unload Me
End Sub
Private Sub LB2_Click()
End Sub
Private Sub UserForm_Initialize()
LB1.AddItem (Sheet1.Range("a1"))
LB1.AddItem (Sheet1.Range("b1"))
LB1.AddItem (Sheet1.Range("c1"))
LB1.AddItem (Sheet1.Range("d1"))
LB1.AddItem (Sheet1.Range("e1"))
LB1.AddItem (Sheet1.Range("f1"))
LB1.AddItem (Sheet1.Range("g1"))
LB1.AddItem (Sheet1.Range("h1"))
LB1.AddItem (Sheet1.Range("i1"))
LB1.AddItem (Sheet1.Range("j1"))
LB1.AddItem (Sheet1.Range("k1"))
End Sub
Sub Rando()
Dim lc As Range
Set lc = Cells.Find("*", [a1], , , xlByColumns, xlPrevious)
Dim UniqueList() As String
Dim X As Long
Dim Rng1 As Range
Dim c As Range
Dim Unique As Boolean
Dim Y As Long
Dim lc As Long
Set Rng1 = Sheets("Sheet1").Range("Data(1)")
Y = 1
ReDim UniqueList(1 To Rng1.Rows.Count)
For Each c In Rng1
If Not c.Value = vbNullString Then
Unique = True
For X = 1 To Y
If UniqueList(X) = c.Text Then
Unique = False
End If
Next
If Unique Then
Y = Y + 1
Me.LB1.AddItem (c.Text)
UniqueList(Y) = c.Text
End If
End If
Next
End Sub
Display More
Re: Receiving error codes with using user form to rearrange and remove columns
its not that its an error - its that it is not copying the entire column.. its copying row 1 only... also, there is an 'error on resume next' line in there because for some reason autofilter doesn't like tables... it ends up converting it back to a range on its own so I just added a line to remove the table at the beginning.. and the on error resume next in case its not a table yet.
Re: Receiving error codes with using user form to rearrange and remove columns
I sent the workbook - if you press control d to open the userform, then click on "open column editing tool", then move some columns, then press filter
***Note - the only tab that can be on the workbook is sheet1 and then results will go into sheet 2, which is created at the beginning of this particular sub
I am just a dynamic userform... so, want it to be able to
remove columns/rearrange them
filter by criteria with checkboxes, then have the option to filter by date ranges for those columns that have dates, etc.
Option to build your own pivot table with the area for them to choose which filters to add where.
I have a lot of it well under way.. but ive hit a road block at the column deleting/sorting. The form I am having trouble with the code is the one titled "removereorder"
It is bringing over the correct columns but it is only bringing over the header...
any help or suggestions would be very much appreciate!
Re: Conditional Formatting Non Blank Cells n Pivot Table
Well - the spreadsheet gets refreshed with data, then the macro runs which adds these sheets..
Re: Conditional Formatting Non Blank Cells n Pivot Table
So I Used this... Just need to get it to not apply to the first column , last row, or first row. Can anyone tell me how to make the fill of these ranges white?
Hi, I am trying to figure the VB code to highlight or Fill all Non-Blank Cells within a pivot table range (range is different each time I run the macro but the pivot table name will always be "PivotTable1" and the worksheet its on will always be named "Who's On 1st".
So, the columns that this will not int he pivot table that this will not need to apply to is the first column, the first row, and the last row (Column Label, Row Label, and Grand Total)
Color to highlight/Fill = 204
Anyone know how to do this??
Hi, I have a table (Table1) starting at row 17 and ends at different #s depending on the workload for that day. Columns will always be from A:AT. In row 16, just above the table, I am trying to figure out the best VBA formula to count the number of non blank cells in each column and display that total for each column.. so, in A16,B16,C16, etc...
I was using the formula =SUBTOTAL function but am running into problems... Any help on that would greatly be appreciated!
Another random question: I made a custom slicer (colors) and then applied it to my 6 slicers in the worksheet but noticed that the VBA code for doing that (with record) is ridiculously long... is there a more efficient way to do that? I was duplicating SlicerStyleDark1 , then modifying it (Now SlicerStyleDark2 after the duplication) to have the "Whole Slicer" background black with a font of light blue, and then changing the header font to light blue. Obviously I can just leave the slicer as is, but any suggestions there would be great... just dont know and havent seen how to do that before.
Thanks!
Hi All, so I have been working on this macro for the past day and I happened to also update to Office 2016 today. Now, I am getting a compile error = Expected Variable or Function for every one of my Range or Selection code lines... does anyone know if something changed... or what is happening here? here it the code... first error occurs at line "Range(Selection, Selection.End(xlDown)).Select" right after the Range("Q24").Select line
[/COLOR][COLOR=#333333]Option Explicit[/COLOR]Sub Hearings()' Application.ScreenUpdating = False Application.StatusBar = False Application.DisplayAlerts = False Application.EnableEvents = False Application.Calculation = xlCalculationManual' Sheets("FLHearingsMaster").Select Range("Q24").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.ClearContents' Dim a, i As Long, myMin As String, AMPM As String, m As Object With Range("J24", Range("J" & Rows.Count).End(xlUp)) a = .Value With CreateObject("VBScript.RegExp") .IgnoreCase = True .Pattern = "(\d{1,2})( *([ap]m)|:(\d{2}) *([ap]m)?|(\d{2}) *([ap]m))" For i = 1 To UBound(a, 1) If TypeName(a(i, 1)) = "Double" Then a(i, 1) = _ Format$(a(i, 1), "hh:mm am/pm") If .test(a(i, 1)) Then Set m = .Execute(a(i, 1))(0).submatches myMin = m(3) & m(5) If myMin = "" Then myMin = "00" AMPM = m(2) & m(4) & m(6) If Trim$(AMPM) = "" Then Select Case Val(m(0)) Case 8 To 11: AMPM = " AM" Case Else: AMPM = " PM" End Select End If If Trim$(AMPM) = "" Then AMPM = " AM" a(i, 1) = m(0) & ":" & myMin & " " & AMPM Else a(i, 1) = "" End If Next End With With .Columns(-4) .Value = a: .NumberFormat = "h:mm AM/PM" End With End With Range("M1:N1").Value = Now' Range("I24").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Range("Q24").Select ActiveSheet.Paste Range("R24").Select ActiveSheet.Paste Range("S24").Select ActiveSheet.Paste Range("T24").Select ActiveSheet.Paste Range("U24").Select ActiveSheet.Paste' ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=2, _ Criteria1:=Array("Broward", "Miami-Dade", "Palm Beach"), Operator:=xlFilterValues Range("Table_FLHearingsMaster[[#Headers],[Office Coverage]]").Select ActiveCell.FormulaR1C1 = "FTL" Range("Table_FLHearingsMaster[[#Headers],[FTL]]").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Application.CutCopyMode = False ActiveSheet.ShowAllData' ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=2, _ Criteria1:=Array("Hillsborough", "Pasco", "Pinellas"), Operator:=xlFilterValues Range("Table_FLHearingsMaster[[#Headers],[FTL]]").Select ActiveCell.FormulaR1C1 = "TPA" Range("Table_FLHearingsMaster[[#Headers],[TPA]]").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Application.CutCopyMode = False ActiveSheet.ShowAllData' ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=20 _ , Criteria1:="<>FTL", Operator:=xlAnd, Criteria2:="<>TPA" Range("Table_FLHearingsMaster[[#Headers],[TPA]]").Select ActiveCell.FormulaR1C1 = "Other" Range("Table_FLHearingsMaster[[#Headers],[Other]]").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Range("Table_FLHearingsMaster[[#Headers],[Other]]").Select ActiveCell.FormulaR1C1 = "Office Coverage" Application.CutCopyMode = False ActiveSheet.ShowAllData' ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=4 _ , Criteria1:="" Range("Table_FLHearingsMaster[[#Headers],[Hearing Time]]").Select ActiveCell.FormulaR1C1 = "Missing" Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Application.CutCopyMode = False Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select ActiveCell.FormulaR1C1 = "Hearing Time" ActiveSheet.ShowAllData' ActiveSheet.ListObjects("Table_FLHearingsMaster").Range.AutoFilter Field:=7, _ Criteria1:="=" Range("Table_FLHearingsMaster[[#Headers],[Attorney Attending Hearing]]").Select ActiveCell.FormulaR1C1 = "Missing" Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Range("Table_FLHearingsMaster[[#Headers],[Missing]]").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "Attorney Attending Hearing" ActiveSheet.ShowAllData' Application.Calculation = xlCalculationAutomatic Range("$R$24").Select ActiveCell.FormulaR1C1 = "=IF((RC[-10]=""Missing""), ""Yes"", ""No"")" Range("$R$24").Select Range("$R$24").Copy Selection.AutoFill Destination:=Range( _ "Table_FLHearingsMaster[Missing Hearing Attorney]") Columns("R:R").Copy Columns("R:R").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False' Range("$Q$24").Select ActiveCell.FormulaR1C1 = "=TEXT(RC[-13],""mmm-yyyy "")" Range("$Q$24").Select Range("$Q$24").Copy Selection.AutoFill Destination:=Range( _ "Table_FLHearingsMaster[Hearing Month Year]") Columns("Q:Q").Copy Columns("Q:Q").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False' Range("S24").Select ActiveCell.FormulaR1C1 = "=IF((RC[-14]=""Missing""), ""Yes"", ""No"")" Range("S24").Select Selection.Copy Application.CutCopyMode = False Selection.AutoFill Destination:=Range( _ "Table_FLHearingsMaster[Missing Hearing Time]")' Range("$T$24").Select ActiveCell.FormulaR1C1 = "=IF((RC[-5]>=TODAY()),""Yes"", ""No"")" Range("$T$24").Select Range("$T$24").Copy Selection.AutoFill Destination:=Range( _ "Table_FLHearingsMaster[Sale Date Set]") Columns("T:T").Copy Columns("T:T").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Application.Calculation = xlCalculationManual' Rows("22:22").Select Selection.NumberFormat = "0" Range("Table_FLHearingsMaster").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone Selection.Borders(xlEdgeLeft).LineStyle = xlNone Selection.Borders(xlEdgeTop).LineStyle = xlNone Selection.Borders(xlEdgeBottom).LineStyle = xlNone Selection.Borders(xlEdgeRight).LineStyle = xlNone Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone' Range("Table_FLHearingsMaster[#All]").Select ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort.SortFields.Clear ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _ "Table_FLHearingsMaster[New Hearing Date]"), SortOn:=xlSortOnValues, Order _ :=xlAscending, DataOption:=xlSortNormal ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _ "Table_FLHearingsMaster[County]"), SortOn:=xlSortOnValues, Order:= _ xlAscending, DataOption:=xlSortNormal ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _ "Table_FLHearingsMaster[Hearing Time]"), SortOn:=xlSortOnValues, Order:= _ xlAscending, DataOption:=xlSortNormal ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort.SortFields.Add Key:=Range( _ "Table_FLHearingsMaster[Attorney Attending Hearing]"), SortOn:=xlSortOnValues _ , Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("FLHearingsMaster").ListObjects( _ "Table_FLHearingsMaster").Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With' Application.Calculation = xlCalculationAutomatic Range("BI24").Select ActiveCell.FormulaR1C1 = "=CLEAN((TRIM(PROPER(RC[-51]))))" Range("BI24").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste Columns("BI:BI").Copy Columns("BI:BI").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("BI24").Select Range("BI24").Copy Range(Selection, Selection.End(xlDown)).Select Selection.Copy Range("J24").Select ActiveSheet.Paste Application.CutCopyMode = False With Selection .HorizontalAlignment = xlLeft End With Application.Calculation = xlCalculationManual' Columns("BI:BI").Delete Shift:=xlToLeft Range("Table_FLHearingsMaster[#All]").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin End With Selection.RowHeight = 13' ActiveWindow.ScrollColumn = 1 Cells.Select' Application.ScreenUpdating = True Application.StatusBar = True Application.DisplayAlerts = True Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic [COLOR=#333333]End Sub[/COLOR][COLOR=#333333]
[/COLOR]
Re: Help Debugging long sorting, labeling and highlighting macro
Okay. Sorry about that. Attached is the document with the code.
I am getting an error at line 126 - Invalid procedure call or argument
What I am trying to do at that point is filter out the data and input text into the visible cells in column AJ depending on the filtering..
so,
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="<>" ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$AJ$").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Complaint Sent To Court - Not Filed"
ActiveSheet.ShowAllData
'
Here, I am filtering on column 23 and if it not blank, I am putting in "Complaint Sent To Court - Not Filed" - for everything that is visible. At the end of all of this i am going to create a pivot using the descriptions from column AJ.
I have attached a better example doc, with the code.
Thanks
Re: Help Debugging long sorting, labeling and highlighting macro
2nd part of code..
[COLOR=#333333] ActiveSheet.ShowAllData[/COLOR] On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$L1:$L" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$S1:$S" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$R1:$R" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$L1:$L" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$R1:$R" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$L1:$L" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$L1:$L" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=1, Criteria1:=RGB(255 _
, 0, 0), Operator:=xlFilterCellColor
Sheets("Sheet2").Select
Sheets("Sheet2").Copy After:=Sheets(2)
Sheets("Sheet2 (2)").Select
Range("$A1:$A").AutoFilter Field:=1, Operator:= _
xlFilterNoFill
Rows("1:1").Select
Selection.EntireRow.Hidden = True
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
ActiveWorkbook.Worksheets("Sheet2 (2)").AutoFilter.Sort.SortFields.Clear
ActiveSheet.ShowAllData
Rows("1:1").Select
Selection.EntireRow.Hidden = False
Sheets("Sheet2 (2)").Name = "Missing Dates"
Cells.Select
Sheets("Sheet2").Name = "Complaint Dept. Report"
Sheets("Complaint Dept. Report").Select
Cells.Select
Application.ScreenUppdating = True
Application.StatusBar = True
Application.DisplayAlerts = True [COLOR=#333333]End Sub
[/COLOR]
Display More
Hi - I keep trying to fix this macro and feel like I am making things worse. At my wits end.. any help would be appreciated with just looking and pointing out things you know for a fact are going to throw errors...
' ComplaintDept Macro
'
Application.ScreenUpdating = False
Application.StatusBar = False
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("Sheet1").Activate
Rows("1:4").Select
Range("A4").Activate
Selection.Delete Shift:=xlUp
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Sheets("Sheet2").Select
ActiveSheet.Paste
Selection.RowHeight = 15
Cells.Select
Cells.EntireColumn.AutoFit
Range("A2").Select
Rows("2:2").EntireRow.AutoFit
Sheets("Sheet1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
ActiveWorkbook.Worksheets("Sheet2").Activate
Columns("D:D").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="Sample", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
ActiveSheet.Range("A$1:$AI10000").AutoFilter Field:=4, Criteria1:=RGB(255 _
, 199, 206), Operator:=xlFilterCellColor
Cells.Select
ActiveSheet.Range("$A$1:$AI10000").Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
ActiveSheet.ShowAllData
Cells.Select
ActiveSheet.Sort.SortFields.Add Key:=Range("A2:A10000" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet2").Sort
.SetRange Range("A1:AI15000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A1:$AI15000").RemoveDuplicates Columns:=1, Header:= _
xlYes
Cells.Select
With Selection.Font
.Name = "Arial"
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("$AJ$1").Select
ActiveCell.FormulaR1C1 = "Status Bucket"
Selection.AutoFilter
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A5").CurrentRegion, , xlYes).Name = "Table"
Rows("1:1").EntireRow.AutoFit
Columns("A:C").EntireColumn.AutoFit
Range("A1:AI1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Rows("1:1").RowHeight = 41.25
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("B2").Select
ActiveWindow.FreezePanes = True
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$AJ").SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Complaint Sent To Court - Not Filed"
ActiveSheet.ShowAllData
'
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="<>"
Range("AJ2:AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Verified Received - Not Sent"
ActiveSheet.ShowAllData
'
'
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
Range("AJ2:AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Complaint Sent to Client - Not Received"
ActiveSheet.ShowAllData
'
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
Range("$AJ2:$AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Complaint Prepared - Not Sent"
ActiveSheet.ShowAllData
'
'
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="<>"
Range("$AJ2:$AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Pending Complaint Prep"
ActiveSheet.ShowAllData
'
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=12, Criteria1:="="
Range("$AJ2:$AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Pending Title Exam"
ActiveSheet.ShowAllData
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=27, Criteria1:=Array( _
"Appointment for a Guardian Ad-Litem/Probate", "Awtg BKY Pleading Validation", "Awtg Consumer Response", _
"Awtg Dual Track Review", "Awtg Fee Approval", "Awtg Figures", "Awtg Filed Order", "Awtg Filed Pleading", _
"Awtg FPOC", "Awtg Funds Received", "Awtg Instructions from Client to Proceed", "Awtg LMM Portal", _
"Awtg Plan Confirmation", "Awtg Referral", "Awtg Standing Clarification", "Fair Debt Dispute", _
"HOA Review", "Mediation", "New Referral Requested", "Payment Dispute", "Pending BK Review", "RESPA", "Sale Cancellation", _
"Sale Moratorium", "Sale Rescission", "Sale Reset/PP", "Third Party Ligation", "Title Defect", "Title Defect Lender Managed", "Vesting Issue"), _
Operator:=xlFilterValues
Range("$AJ1:$AJ" & lr).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "Delayed"
'
ActiveSheet.ShowAllData
Columns("AH").ColumnWidth = 39
Rows("1:1").Select
Selection.RowHeight = 76.5
Rows("1:1").Select
With Selection
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("M").ColumnWidth = 16
Columns("P").ColumnWidth = 16
Columns("Q:T").ColumnWidth = 16
Columns("U").ColumnWidth = 16
Columns("X").ColumnWidth = 16
Columns("AE:AF").ColumnWidth = 16
Columns("V:V").ColumnWidth = 24
Columns("AH:AH").ColumnWidth = 47
ActiveSheet.Range("AJ1:AJ" & lr).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
Selection.AutoFilter
Columns("AA").ColumnWidth = 36
Columns("S").ColumnWidth = 10
Columns("I").ColumnWidth = 10
Columns("I").ColumnWidth = 15
Columns("D").ColumnWidth = 35
Columns("E").ColumnWidth = 26
Rows("1:1").Select
Selection.AutoFilter
'
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=27, Criteria1:= _
"Reforeclosure", Operator:=xlOr, Criteria2:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A$1:$AJ$" & lr).Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
Range("$U1:$U" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("S1:S").SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
ActiveSheet.ShowAllData
On Error Resume Next
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=23, Criteria1:="="
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=21, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=19, Criteria1:="<>"
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.AutoFilter Field:=18, Criteria1:="<>"
If ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range.SpecialCells(xlCellTypeVisible).Count > 0 Then
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$R1:$R" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveWorkbook.Sheets("Sheet2").ListObjects("Table").Range("$A1:$A" & lr).SpecialCells(xlCellTypeVisible).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else: ActiveSheet.ShowAllData
End If
'
Display More
Re: Vba code for a formula
So i have just one more question but want to provide the excel shet to make it easier for you, how do i do that?
Re: Vba code for a formula
Disregard - I got it working, thanks!!