Finding Certain Values in Row 6 and filtering them

drozek

Board Regular
Joined
Aug 3, 2011
Messages
67
So I have this macro written for my sales team. My boss asked me since G6 "Ship - To" can be in A6, B6, C6, D6, E6 at anytime. Can I locate it and then do my filters. and sort.

Any help with that?

VBA Code:
Sub ColorEnds()
'
' ColorEnds Macro
' Ctrl+Shift+E

'
    Range("H7").Select
    ActiveWindow.FreezePanes = True
    If Range("G6") <> "Ship - To" Then
    MsgBox "Only One Ship To Selected in SAP! or No Ship To's  in SAP", vbOKOnly, "WARNING!"
    Exit Sub
    End If
    Cells.Select
    Cells.EntireColumn.AutoFit
    Rows("6:6").Select
    Selection.AutoFilter
    Cells.Select
    Cells.EntireColumn.AutoFit
    Call ShipTo
  With ActiveSheet.Range("A5:G" & Range("A" & Rows.Count).End(3).Row)
    .AutoFilter 1, "Sales Input"
    .AutoFilter 7, "<>Total"
    Columns("A:A").ColumnWidth = 0
    Rows("1:5").Select
    Range("A5").Activate
    Selection.EntireRow.Hidden = True
  End With
  'Call ShipTo
End Sub

Sub ShipTo()
Range("G6").CurrentRegion.Select
    Selection.Sort Key1:=Range("G6"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal

End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
One way.
VBA Code:
Sub ColorEnds()
'
' ColorEnds Macro
' Ctrl+Shift+E

'
    Range("H7").Select
    ActiveWindow.FreezePanes = True

    If Not Range("A6:E6").Find(What:="Ship - To", LookAt:=xlPart) Is Nothing Then
        Range("G6").Value = "Ship - To"
    End If

    If Range("G6") <> "Ship - To" Then
        MsgBox "Only One Ship To Selected in SAP! or No Ship To's  in SAP", vbOKOnly, "WARNING!"
        Exit Sub
    End If
    Cells.Select
    Cells.EntireColumn.AutoFit
    Rows("6:6").Select
    Selection.AutoFilter
    Cells.Select
    Cells.EntireColumn.AutoFit
    Call ShipTo
    With ActiveSheet.Range("A5:G" & Range("A" & Rows.Count).End(3).Row)
        .AutoFilter 1, "Sales Input"
        .AutoFilter 7, "<>Total"
        Columns("A:A").ColumnWidth = 0
        Rows("1:5").Select
        Range("A5").Activate
        Selection.EntireRow.Hidden = True
    End With
    'Call ShipTo
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top