JMCN
2004-09-03 18:49:54 UTC
hello
i'm currently converting the excel 97 macros to excel 2003. i have the
following run time error 1004: select method of range class failed.
code is below... there's more to the code but for starters... it
errors on the
"Range("B2").Select ". i don't understand if the range contains the
data then why is there an error message that the range class failed in
excel 2003?
any advise would be appreciated.
thanks - jung
***************************************
Dim lastrow As Integer
If Workbooks.Count <> 2 Then
Beep
MsgBox "FUNCTION CANCELLED! " + Chr$(13) + Chr$(13) & "The
Macro workbook and the workbook to be formatted should be the only
workbooks open.", vbCritical
Exit Sub
End If
'determine last row of data
ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row
'General formatting
ActiveWindow.Zoom = 75
Cells.Font.Name = "Arial"
Range("B2").Select 'run-time error 1004: select method of range class
failed.
ActiveWindow.FreezePanes = True
Rows("2:" & lastrow).Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom
'Column Header formatting
Range("A1:N1").Select
Selection.Font.ColorIndex = 5
Selection.Font.Bold = True
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
End With
Range("M1") = "Days Int Due"
Range("N1") = "Days Prin Due"
Rows("1:1").RowHeight = 39
'rest of code....
i'm currently converting the excel 97 macros to excel 2003. i have the
following run time error 1004: select method of range class failed.
code is below... there's more to the code but for starters... it
errors on the
"Range("B2").Select ". i don't understand if the range contains the
data then why is there an error message that the range class failed in
excel 2003?
any advise would be appreciated.
thanks - jung
***************************************
Dim lastrow As Integer
If Workbooks.Count <> 2 Then
Beep
MsgBox "FUNCTION CANCELLED! " + Chr$(13) + Chr$(13) & "The
Macro workbook and the workbook to be formatted should be the only
workbooks open.", vbCritical
Exit Sub
End If
'determine last row of data
ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row
'General formatting
ActiveWindow.Zoom = 75
Cells.Font.Name = "Arial"
Range("B2").Select 'run-time error 1004: select method of range class
failed.
ActiveWindow.FreezePanes = True
Rows("2:" & lastrow).Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom
'Column Header formatting
Range("A1:N1").Select
Selection.Font.ColorIndex = 5
Selection.Font.Bold = True
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
End With
Range("M1") = "Days Int Due"
Range("N1") = "Days Prin Due"
Rows("1:1").RowHeight = 39
'rest of code....