VBA code to select last cell in row with data

ronnie76

Board Regular
Joined
Jul 26, 2007
Messages
101
I have a row of formulas that reference other sheets in my workbook (i.e. Cell A4=Sheet2!A1, Cell B4=Sheet2!B1, etc). I need to have VBA find the last cell in that row with data. I tried "End(xlToRight).Column" but it goes all the way to the end because all of the cells have formulas. I need to find the last cell that is empty of data or maybe >0 would work. Sorry if this is confusing. Thanks for any and all help.
 
when looking to the last example you posted, that's the same example as mine, only not the same row (you said row 4 in your original post)

To get the required result you only need to replace the 4 in my first code by 2.

You wouldn't knock at each door in a street to ask if a certain mister Jones is living there, if you can FIND it in an addressbook. So avoid code which is looping, even when it is reading more easily at first sight: the other code will also read easily once you understand how FIND works
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I'm glad some found solutions that worked in this thread - none worked for me, but I found this on MrExcel, and it worked perfect !

Code:
Range("A:A".Find("").Select

I needed to go to the last row with data (NOT 'ghost data' - that was an issue with "tables"), and go there - very grateful to whoever posted that....
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,788
Members
449,049
Latest member
greyangel23

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