Find Last cell with Data in Range

berty2000

Board Regular
Joined
Mar 29, 2011
Messages
71
Hi guys

Im sure this is simple but i cant seem to get anything to work correctly.

Im trying to make active cell the last cell with data in from a range all in the same row.

Code:
ActiveSheet.Range("E5:J5").End(xlToRight).Select

xlToRight goes to the first number and xlToLeft goes outside the range

Any ideas what i'm doing wrong please?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi guys

Im sure this is simple but i cant seem to get anything to work correctly.

Im trying to make active cell the last cell with data in from a range all in the same row.

Code:
ActiveSheet.Range("E5:J5").End(xlToRight).Select

xlToRight goes to the first number and xlToLeft goes outside the range

Any ideas what i'm doing wrong please?

Try it this way...

ActiveSheet.Cells(5, "K").End(xlToLeft).Select

The Column K reference because it is one column past the end of the range you specified (E5:J5).
 
Upvote 0
That works well, but if there is nothing in the range E:J it will select column C were I have other data, thats why I trying to do it from a range
 
Upvote 0
That works well, but if there is nothing in the range E:J it will select column C were I have other data, thats why I trying to do it from a range

Give this a try then...

Cells(5, Application.Max(5, ActiveSheet.Cells(5,"K").End(xlToLeft).Column)).Select
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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