Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assigning cell values to variables | Excel Discussion (Misc queries) | |||
Passing excel cell values as sql variables | Excel Programming | |||
Assigning cell address components to variables | Excel Programming | |||
Assigning values from a selected range to individual variables | Excel Programming |