Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default out of range error for range value

Hi;

i'm trying to capture a value in a range. I have the following codeattched
to the click action on a button in my "Results" sheet:

Dim LastDataRow As Integer

LastDataRow = Worksheets("Data").Range("E1").Value

When the above line is reached, I get a "Run time error '9' Subscript out of
range" error message.

Cell E1 of the worksheet labelled "Data" has the value 9 in it. I tried
displaying the value of it by the line :

MsgBox Worksheets("Data").Range("E1").Value

which was placed just before the problem line. When the MsgBox line
executed, the value was blank in the message box.

I'm at a loss as to what the problem is. Any help is greatly appreciated.

--
JJFJR
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default out of range error for range value

Hi,

Yeah just change Worksheets to Sheets. Different Collections so its not
registering what you are trying to do.

Any Problems then give me a shout.

James

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default out of range error for range value

Hi JJFJR,

The "Subscript out of range" message indicates a failure to find a worksheet
named 'Data'.

Check that there are no spaces at the beginning or end of the sheet's name.


---
Regards,
Norman



"jjfjr" wrote in message
...
Hi;

i'm trying to capture a value in a range. I have the following codeattched
to the click action on a button in my "Results" sheet:

Dim LastDataRow As Integer

LastDataRow = Worksheets("Data").Range("E1").Value

When the above line is reached, I get a "Run time error '9' Subscript out
of
range" error message.

Cell E1 of the worksheet labelled "Data" has the value 9 in it. I tried
displaying the value of it by the line :

MsgBox Worksheets("Data").Range("E1").Value

which was placed just before the problem line. When the MsgBox line
executed, the value was blank in the message box.

I'm at a loss as to what the problem is. Any help is greatly appreciated.

--
JJFJR



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default out of range error for range value

Sorry, just ignore what I wrote as its not correct, an off moment!

James

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default out of range error for range value

Interesting to note however that the OP tested with Msgbox
Worksheets("Data").Range("E1").value and did NOT get the same error message
.... which they should have if the problem is the worksheet name. I will be
interested to see what they respond to this!

Bill


"Norman Jones" wrote in message
...
Hi JJFJR,

The "Subscript out of range" message indicates a failure to find a
worksheet named 'Data'.

Check that there are no spaces at the beginning or end of the sheet's
name.


---
Regards,
Norman



"jjfjr" wrote in message
...
Hi;

i'm trying to capture a value in a range. I have the following
codeattched
to the click action on a button in my "Results" sheet:

Dim LastDataRow As Integer

LastDataRow = Worksheets("Data").Range("E1").Value

When the above line is reached, I get a "Run time error '9' Subscript out
of
range" error message.

Cell E1 of the worksheet labelled "Data" has the value 9 in it. I tried
displaying the value of it by the line :

MsgBox Worksheets("Data").Range("E1").Value

which was placed just before the problem line. When the MsgBox line
executed, the value was blank in the message box.

I'm at a loss as to what the problem is. Any help is greatly appreciated.

--
JJFJR







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default out of range error for range value

Hi William,

Good point.

I might assume that the sheet name had been spelled correctly in one line
and wrongly in the other, but that would not explain the empty value
returned by the Msgbox.

---
Regards,
Norman



"William Benson" wrote in message
...
Interesting to note however that the OP tested with Msgbox
Worksheets("Data").Range("E1").value and did NOT get the same error
message ... which they should have if the problem is the worksheet name. I
will be interested to see what they respond to this!

Bill


"Norman Jones" wrote in message
...
Hi JJFJR,

The "Subscript out of range" message indicates a failure to find a
worksheet named 'Data'.

Check that there are no spaces at the beginning or end of the sheet's
name.


---
Regards,
Norman



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default out of range error for range value

Also, while I do not have enough info to answer your stated problem, I will
caution against using integer type variables to hold row numbers except
under VERY controlled circumstances.

INTEGER: -32,768 to 32,767 [Note: Rows can go to 65,536!]
LONG: -2,147,483,648 to 2,147,483,647

"jjfjr" wrote in message
...
Hi;

i'm trying to capture a value in a range. I have the following codeattched
to the click action on a button in my "Results" sheet:

Dim LastDataRow As Integer

LastDataRow = Worksheets("Data").Range("E1").Value

When the above line is reached, I get a "Run time error '9' Subscript out
of
range" error message.

Cell E1 of the worksheet labelled "Data" has the value 9 in it. I tried
displaying the value of it by the line :

MsgBox Worksheets("Data").Range("E1").Value

which was placed just before the problem line. When the MsgBox line
executed, the value was blank in the message box.

I'm at a loss as to what the problem is. Any help is greatly appreciated.

--
JJFJR



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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM


All times are GMT +1. The time now is 10:19 PM.

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"