Excel 2007 VB 6.5
I'm trying to use variables (defined) to set the range in the following example instead of actual cell (r,c) references. It does not work , I have tried various ways, it faults out on the line ".SetRange = ActiveSheet.Range(Cells(BrakeSheetPullRow, 2), Cells(BrakeSheetPullRow + 10, uCol)).Select 'ActiveSheet.Range(Cells(5, c1), Cells(20, c2))
If I substitute .SetRange Range("B17:IQ20") the code works.
However when the program gets to the line ; ActiveWorkbook.Worksheets("Brakes").Range(Cells(BrakeSheetPullRow, 2), Cells(BrakeSheetPullRow + 10, uCol)).Select
It highlights the range demonstrating that it recognises it ..
The entire relevant code is:
Dim BrakeSheetPullRow definition
BrakeSheetPullRow=2
.
ActiveWorkbook.Worksheets("Brakes").Range(Cells(BrakeSheetPullRow, 2), Cells(BrakeSheetPullRow + 10, uCol)).Select 'ow+10,uCol)) was Worksheets("Brakes").Range("B17:IQ20").Select
'ActiveWorkbook.Worksheets("Brakes").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Brakes").Sort.SortFields.Add Key:=Range(Cells(BrakeSheetPullRow + 10, 2), Cells(BrakeSheetPullRow + 10, uCol)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Brakes").Sort
.SetRange = ActiveSheet.Range(Cells(BrakeSheetPullRow, 2), Cells(BrakeSheetPullRow + 10, uCol)).Select ' sample code; ActiveSheet.Range(Cells(5, c1), Cells(20, c2))
.Header = xlGuess
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
I get run time error; 1004; Application defined or object defined error
Can anybody shed light on why this does not work?
I get run time error; 1004; Application defined or object defined error
Bookmarks