Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run-time error '1004': Method 'Cells' of object _Global failed

Hello,

I have built a macro in Excel 2000 that I want to run on any active sheet
that I am on in a workbook. However, I get the error in the subject line,
above, for the following code:

While Not LastColumn
If Cells(1, traces + 1).Value = "Volt" Then
traces = traces + 1
Else
LastColumn = True
End If
Wend

I know that typically one specifies the sheet by identifying Cells with
Sheet(1) or whatever, but I don't want this macro to be tied to any specific
sheet, only the one that is presently active.

Does anyone have any ideas?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run-time error '1004': Method 'Cells' of object _Global failed

If your code does not hit exactly the string "Volt" then it will error out as
it will continue right through the end of the columns. Check the value of
traces when the error occures and I bet it will be 256. I would be inclined
to put in a second stop conditon and to make the seach for Volt be a little
more bulletproof, something like this

While Not LastColumn or traces = 255
If ucase(trim(Cells(1, traces + 1).Value)) = "VOLT" Then
traces = traces + 1
Else
LastColumn = True
End If
Wend

--
HTH...

Jim Thomlinson


"Fran D" wrote:

Hello,

I have built a macro in Excel 2000 that I want to run on any active sheet
that I am on in a workbook. However, I get the error in the subject line,
above, for the following code:

While Not LastColumn
If Cells(1, traces + 1).Value = "Volt" Then
traces = traces + 1
Else
LastColumn = True
End If
Wend

I know that typically one specifies the sheet by identifying Cells with
Sheet(1) or whatever, but I don't want this macro to be tied to any specific
sheet, only the one that is presently active.

Does anyone have any ideas?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run-time error '1004': Method 'Cells' of object _Global failed

Actually, the value of traces is still at the initialized value of 0 when it
fails, so it didn't even get past the first column. Yes, that column has the
value "Volt" in that position [Cells(1,1)].

Any other ideas?

"Jim Thomlinson" wrote:

If your code does not hit exactly the string "Volt" then it will error out as
it will continue right through the end of the columns. Check the value of
traces when the error occures and I bet it will be 256. I would be inclined
to put in a second stop conditon and to make the seach for Volt be a little
more bulletproof, something like this

While Not LastColumn or traces = 255
If ucase(trim(Cells(1, traces + 1).Value)) = "VOLT" Then
traces = traces + 1
Else
LastColumn = True
End If
Wend

--
HTH...

Jim Thomlinson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run-time error '1004': Method 'Cells' of object _Global failed

I still need some help here. Does anyone have any ideas?

"Fran D" wrote:

Hello,

I have built a macro in Excel 2000 that I want to run on any active sheet
that I am on in a workbook. However, I get the error in the subject line,
above, for the following code:

While Not LastColumn
If Cells(1, traces + 1).Value = "Volt" Then
traces = traces + 1
Else
LastColumn = True
End If
Wend

I know that typically one specifies the sheet by identifying Cells with
Sheet(1) or whatever, but I don't want this macro to be tied to any specific
sheet, only the one that is presently active.

Does anyone have any ideas?

Thanks in advance.

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
Run-time error '1004': Method 'Range' of object '_Global' failed Neild Excel Programming 0 February 12th 06 11:43 PM
Run-time error '1004': Method 'Range' of object '_Global' failed Tim Williams Excel Programming 2 February 12th 06 10:01 PM
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
Error 1004: Method 'Cells' of object '_Global' failed LT Excel Programming 2 October 31st 03 04:47 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


All times are GMT +1. The time now is 07:16 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"