Last Col in Range

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,099
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I was given this for a range from Y to the last used Col from CP in Row eRow,
VBA Code:
Set iRange = Range(Range("Y" & eRow), Range("CQ" & eRow).End(xlToLeft))
And it's worked many times fine, until suddenly iRange.address is $Y37:$CP$37
So I assumed there was a rogue invisible character somewhere and tried this
VBA Code:
                    kcol = 94
                    Do Until Val(Cells(eRow, kcol)) > 0
                    Cells(eRow, kcol) = ""
                    kcol = kcol - 1
                    Loop
                    Set iRange = Range(Range("Y" & eRow), Range("CQ" & eRow).End(xlToLeft))
Thinking that would fix it. But iRange address is still $Y37:$CP$37
What might cause this ?
 
And you're saying this doesn't change if you select CO37 and click the Delete key?
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What do you get if in a blank cell somewhere on the sheet you enter this:
Excel Formula:
=UNICODE(CO37)
 
Upvote 0
Stephen - Yes.
Alex, Typed that into CX37. Clicked away and it changed to #NAME?.
 
Upvote 0
Can you post the dodgy data into a small workbook (making sure there's no sensitive or confidential information), upload to a dropbox site and post the link so we can take a look?
 
Upvote 0
A copy as suggested by Stephen would be ideal. In the meantime try this in the immediate window including the question mark and hit enter (Ctrl+G if you can't see the immediate window) and tell us what it returns.
VBA Code:
? ascw(Range("CO37").value)
 
Upvote 0
Alex, it tells me
Run-time error '5':
Invalid procedure call or argument
Same thing after changing ascw to asc
? Range("CO37").value prints nothing.
Yes, giving you the worksheet wold make it much easier. I don't have Dropbox but may be able to organise something. I'll try.
May take 30 mins.
 
Upvote 0
Because some value there (pairs) include "=". Poss on other sheets. Complete thing has 5.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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