IREALLYambatman
Board Regular
- Joined
- Aug 31, 2016
- Messages
- 63
So I used this code to find the last column letter...
And then when I tried to sort, using that in a range, I get an error.. Is Range("A11", ColumnLetter & 11) not a valid way to define a range? It works for the rest of my script..?
I get the error: Method: Range of Object _Global failed. Is that a bad way to call that range? Is there a better way I should be using?
Code:
With ActiveWorkbook.Worksheets("Edit Here")
LastCol = .Cells(4, .Columns.Count).End(xlToLeft).Column
End With
ColumnLetter = Split(Cells(1, LastCol).Address, "$")(1)
And then when I tried to sort, using that in a range, I get an error.. Is Range("A11", ColumnLetter & 11) not a valid way to define a range? It works for the rest of my script..?
I get the error: Method: Range of Object _Global failed. Is that a bad way to call that range? Is there a better way I should be using?
Code:
ActiveWorkbook.Worksheets("Edit Here").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Edit Here").Sort.SortFields.Add Key:=Range("A11", ColumnLetter & 11), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"salted,SampleID,CCV,ccv,CCB,ccb,MB-,mb-,LCS-,lcs-,LCSD-,lcsd-", DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Edit Here").Sort.SortFields.Add Key:=Range("A13", ColumnLetter & 13), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"salted,Dilution", DataOption:=xlSortNormal
' With ActiveWorkbook.Worksheets("Edit Here").Sort
' .SetRange Range("A1:", ColumnLetter & 1)
' .Header = xlGuess
' .MatchCase = False
' .Orientation = xlLeftToRight
' .SortMethod = xlPinYin
' .Apply
' End With