Thread: [Solved] Sorting Challenge
View Single Post
 
Old 06-22-2012, 08:44 AM
gbaker gbaker is offline Windows 7 32bit Office 2010 32bit
Competent Performer
 
Join Date: May 2012
Posts: 111
gbaker is on a distinguished road
Default Sorting Challenge

Hi Colin,
I finalized the code to work on 4 vendors. I am getting an error at the end.
Compile Error:
Expected End With
Don't understand why I'm getting this error. Can you clarify. See code below.
Code:
Sub SortdataOnly()
With Sheet2
              'get rid of any null strings stored in the cells for Print
            With .Range("Cr2:DE3980")
                         .Value = .Value
             End With
            With .Sort
                     'set up the sort fields for Print on (data tab)
            With .SortFields
                      .Clear
            .Add Key:=Sheet2.Range("Cr2:Cr3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
           .Add Key:=Sheet2.Range("Cs2:Cs3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
            End With
                       'set up the rest of the sort and apply for Print
               .SetRange Sheet2.Range("Cr2:De3980")
              .Header = xlNo
              .MatchCase = False
              .Orientation = xlSortColumns
              .SortMethod = xlPinYin
              .Apply
         End With
With Sheet2
               'get rid of any null strings stored in the cells for BNY
         With .Range("Dq2:Eb3980")
                         .Value = .Value
             End With
            With .Sort
                     'set up the sort fields on BNY on (data tab)
            With .SortFields
                      .Clear
            .Add Key:=Sheet2.Range("Dq2:Dq3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
           .Add Key:=Sheet2.Range("Dr2:Dr3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
            End With
                       'set up the rest of the sort and apply for BNY
               .SetRange Sheet2.Range("Dq2:Eb3980")
              .Header = xlNo
              .MatchCase = False
              .Orientation = xlSortColumns
              .SortMethod = xlPinYin
              .Apply
         End With
With Sheet2
         'get rid of any null strings stored in the cells for Wilde
       With .Range("En2:Ey3980")
                         .Value = .Value
             End With
            With .Sort
                     'set up the sort fields on Wilde on (data tab)
            With .SortFields
                      .Clear
            .Add Key:=Sheet2.Range("En2:En3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
           .Add Key:=Sheet2.Range("Eo2:Eo3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
            End With
                       'set up the rest of the sort and apply for Wilde
               .SetRange Sheet2.Range("En2:Ey3980")
              .Header = xlNo
              .MatchCase = False
              .Orientation = xlSortColumns
              .SortMethod = xlPinYin
              .Apply
         End With
With Sheet2
         'get rid of any null strings stored in the cells for DS Graphics
         With .Range("Fm2:Fx3980")
                         .Value = .Value
             End With
            With .Sort
                     'set up the sort fields on DS Graphics on (data tab)
            With .SortFields
                      .Clear
            .Add Key:=Sheet2.Range("Fm2:Fm3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
           .Add Key:=Sheet2.Range("Fn2:Fn3980"), _
                            SortOn:=xlSortOnValues, _
                            Order:=xlAscending, _
                            DataOption:=xlSortNormal
            End With
                       'set up the rest of the sort and apply for DS Graphics
               .SetRange Sheet2.Range("Fm2:Fx3980")
              .Header = xlNo
              .MatchCase = False
              .Orientation = xlSortColumns
              .SortMethod = xlPinYin
              .Apply
             End With
    End With
 
End Sub
Reply With Quote