Last Col in Range

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,052
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 ?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
It varies. Y to the last populated column before CQ, in any row.
 
Upvote 0
Maybe this?
VBA Code:
Set iRange = Range(Range("Y" & eRow), Range(Cells(eRow, Me.UsedRange.Columns.Count)) 'Replace Me with Sheet variable if needed
 
Upvote 0
Skybot, the debug window says 'Expected list separator or )'
Me.Me.UsedRange.Columns.Count is 100. The correct last col in the row.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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