Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default MS Office Excel 2003 assigning cell values to variables

Hello,

( MS Office Excel 2003 )

I'm getting a runtime 1004 error with for any/each of the following
statements.
I don't want to employ the standard Range("A1") object since the the
A1 is literal string,
and I need more progamatic control hence the Cells method.

The "wrap" variables are non-zero, and temp is not not declared so
that Excel VB
can determine the type as needed.

I've seen on-line doc with stated examples where these should work.

temp = Sheets("Sheet1").Cells(wrap_b, wrap_a).Value2
temp = Cells(wrap_b, wrap_a).Value2
temp = Sheets("Sheet1").Range(Cells(wrap_b, wrap_a), Cells(wrap_b,
wrap_a)).Value2


PS I've never understood the usefulness of the "string" parameter of
the Range() object ...

Thanks, Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default MS Office Excel 2003 assigning cell values to variables

Hmm...

What are the values and types of wrap_a/wrap_b? VBA will round to the
nearest integer, so if wrap_a = 0.49, then you'll get the error you
report, since the value will be coerced to 0.

Of course, using a value then number of rows or columns will also
cause the error.

PS I've never understood the usefulness of the "string" parameter of
the Range() object ...


For one thing, it's easier to read in many cases, especially if one is
used to using A1-style references in XL formulae. For another,

Range("B3:J10")

is arguably easier to write and understand than

Range(Cells(3, 1), Cells(10, 10))

or

Cells(3, 2).Resize(8, 9)

In article .com,
wrote:

Hello,

( MS Office Excel 2003 )

I'm getting a runtime 1004 error with for any/each of the following
statements.
I don't want to employ the standard Range("A1") object since the the
A1 is literal string,
and I need more progamatic control hence the Cells method.

The "wrap" variables are non-zero, and temp is not not declared so
that Excel VB
can determine the type as needed.

I've seen on-line doc with stated examples where these should work.

temp = Sheets("Sheet1").Cells(wrap_b, wrap_a).Value2
temp = Cells(wrap_b, wrap_a).Value2
temp = Sheets("Sheet1").Range(Cells(wrap_b, wrap_a), Cells(wrap_b,
wrap_a)).Value2

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
Assigning cell values to variables Tim Excel Discussion (Misc queries) 3 June 11th 09 04:30 PM
Passing excel cell values as sql variables jai[_2_] Excel Programming 4 December 28th 06 09:41 AM
Assigning cell address components to variables Conan Kelly Excel Programming 1 June 15th 05 06:05 AM
Assigning values from a selected range to individual variables Dr. Schwartz[_3_] Excel Programming 5 January 27th 04 02:27 PM


All times are GMT +1. The time now is 07:29 PM.

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

About Us

"It's about Microsoft Excel"