why is cell.address working for x<200 else giving runtime error

drprd

New Member
Joined
May 7, 2015
Messages
1
The following code
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Dim YrColNumber As Integer
Dim YrColAddress As String
Dim IntColNumber As Integer
Dim IntColAddress As String
Dim CycleNumber As Integer
CycleNumber
= 1
YrColNumber
= 4 + (CycleNumber - 1) * 7
YrColAddress
= Split(Cells(, YrColNumber).Address, "$")(1)
IntColNumber
= YrColNumber + 281
IntColAddress
= Split(Cells(, IntColNumber).Address, "$")(1)
...</code>Works fine for YrColAddress ("D" in this case) but gives a runtime error 1004 "Application-defined or Object-defined error" for IntColAddress.
I have also tried declaring the ...ColNumber variables as long or variants - to no avail. Also I have tested with constant numbers <code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">Split(Cells(, 500).Address, "$")(1)</code> and that does work. Its just variables it seems to not like.
Why would the same formula on similarly declared variables behave so differently. What am I doing wrong here and how can I fix it. If not, is this a known bug for this cell.address operation (where numbers > 200ish sent as variables lead to runtime errors)?
Any kind help on this will be immensely appreciated. Thanks in advance.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I would guess that you're using XL2003, or you're using XL2007+ but the book you have open is in 'Compatibility Mode'

There are only 256 columns in XL versions PRE-2007
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,790
Messages
6,132,709
Members
449,753
Latest member
swastikExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top