Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default excel97: runtime error 1004 select method of range class failed

hi

i receive an error message whenever i try to step through the
following code. i don't know why excel cannot find the cells.select ?
if anyone has an suggestions as to why, it would be greatly
appreciated.

thanks in advance - jung

i only posted a couple of lines below to get the just of the problem.
++++++++++++++++++++++++++++++
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


ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row ' determine last row
of data
ActiveWindow.Zoom = 85
Cells.Font.Name = "Arial"
Cells.Select 'recevie runtime error 1004
Selection.Columns.AutoFit

Range("A1").Select
ActiveCell.FormulaR1C1 = "INTERNAL #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "OBLIGOR #"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel97: runtime error 1004 select method of range class failed

Hi JMCN,

Sorry now I don't have 97....It may be a problem comes from forcus.
Insert "ActiveCell.Activate" before "Cells.Select" line.


Code
-------------------

ActiveCell.Activate
Cells.Select 'recevie runtime error 1004
Selection.Columns.AutoFit

-------------------


Or, simply don't select cells


Code
-------------------

Cells.Columns.AutoFit

-------------------


--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default excel97: runtime error 1004 select method of range class failed

How are you executing the code?

From a commandbutton from the controls toolbar placed on the worksheet?

If yes, try changing its .takefocusonclick property to false. (If it's a
control from that toolbar that doesn't have that property, try adding:

activecell.activate

to the top of your routine (a bug fixed in xl2k).

JMCN wrote:

hi

i receive an error message whenever i try to step through the
following code. i don't know why excel cannot find the cells.select ?
if anyone has an suggestions as to why, it would be greatly
appreciated.

thanks in advance - jung

i only posted a couple of lines below to get the just of the problem.
++++++++++++++++++++++++++++++
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


ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row ' determine last row
of data
ActiveWindow.Zoom = 85
Cells.Font.Name = "Arial"
Cells.Select 'recevie runtime error 1004
Selection.Columns.AutoFit

Range("A1").Select
ActiveCell.FormulaR1C1 = "INTERNAL #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "OBLIGOR #"


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default excel97: runtime error 1004 select method of range class failed

Just an alternate opinion (assuming this code is in a sheet module).
If you are running this from the click event of a commandbutton, then your
problem won't be fixed with activeCell.Activate or Changing TakeFocusOnClick
to false I don't think (although those should be done in xl97 as well).
Since you have ActiveWindow.ActivateNext this would indicate the
activesheet is no longer the worksheet containing the code. Thus the
unqualified Cells.Select refers to the worksheet containing the code and not
the activeworksheet as it would in a general module. The easiest solution
would be to move your code to a general module, then call it from the click
event. The harder solution is to qualify all your references so you state
specifically where the action should take place

Activesheet.Cells.Select vice Cells.select for instance.

unqualified references in a sheet module have an implicit "me" qualifier
me.cells.select

--
Regards,
Tom Ogilvy

"JMCN" wrote in message
om...
hi

i receive an error message whenever i try to step through the
following code. i don't know why excel cannot find the cells.select ?
if anyone has an suggestions as to why, it would be greatly
appreciated.

thanks in advance - jung

i only posted a couple of lines below to get the just of the problem.
++++++++++++++++++++++++++++++
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


ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row ' determine last row
of data
ActiveWindow.Zoom = 85
Cells.Font.Name = "Arial"
Cells.Select 'recevie runtime error 1004
Selection.Columns.AutoFit

Range("A1").Select
ActiveCell.FormulaR1C1 = "INTERNAL #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "OBLIGOR #"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default excel97: runtime error 1004 select method of range class failed

"Tom Ogilvy" wrote in message ...
Just an alternate opinion (assuming this code is in a sheet module).
If you are running this from the click event of a commandbutton, then your
problem won't be fixed with activeCell.Activate or Changing TakeFocusOnClick
to false I don't think (although those should be done in xl97 as well).
Since you have ActiveWindow.ActivateNext this would indicate the
activesheet is no longer the worksheet containing the code. Thus the
unqualified Cells.Select refers to the worksheet containing the code and not
the activeworksheet as it would in a general module. The easiest solution
would be to move your code to a general module, then call it from the click
event. The harder solution is to qualify all your references so you state
specifically where the action should take place

Activesheet.Cells.Select vice Cells.select for instance.

unqualified references in a sheet module have an implicit "me" qualifier
me.cells.select

--
Regards,
Tom Ogilvy

"JMCN" wrote in message
om...
hi

i receive an error message whenever i try to step through the
following code. i don't know why excel cannot find the cells.select ?
if anyone has an suggestions as to why, it would be greatly
appreciated.

thanks in advance - jung

i only posted a couple of lines below to get the just of the problem.
++++++++++++++++++++++++++++++
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


ActiveWindow.ActivateNext
lastrow = Range("A65536").End(xlUp).Row ' determine last row
of data
ActiveWindow.Zoom = 85
Cells.Font.Name = "Arial"
Cells.Select 'recevie runtime error 1004
Selection.Columns.AutoFit

Range("A1").Select
ActiveCell.FormulaR1C1 = "INTERNAL #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "OBLIGOR #"


thank you all for your advice. i forgot to include that i run the
code by clicking the commandbutton1.

thanks again!!!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime 1004 error -- insert method of range class failed. tish Excel Discussion (Misc queries) 1 June 1st 07 04:04 PM
Run-Time error '1004' : Select method of Range class failed [email protected] Excel Discussion (Misc queries) 3 March 9th 07 01:36 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"