Set top =Range("G" & rows.count).end(xlup).row
Main Topics
Browse All TopicsHow do I write this line so that it identifies the last cell in Column G that has a value?
Set top = [G4].End(xlDown)
Thanks,
John
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
rinkydink,
A gentle reminder to please read earlier - and perhaps test - Expert comments before posting
Futher posts should only be made where the proposed solution is demonstrably better than earlier comments, or if the Author has clarified their request further.
In this case while your solution will work, it will be much slower than the earlier comments provided by two highly ranked Experts
Regards
Dave
Hi Dave, I have a problem here. I trust your judgment implicitly but the only one that I can get to work is rinkydink's. Please take a look at ippinto's and rory's suggestions and let me know if they work for you. If they do please take a look at my demo workbook let me know what I'm doing wrong.
Thanks,
John
John,
Rinkydink's code answered a slightly different interpretation of last used cell - which as it turns out is the one you are seeking
Rory and jppinto have provided code that will find the last used value (looking from the bottom up)
Rinkydink's code finds the last cell that procedes the first cell with a "" value (nc which can be blank or "" as per your formula) top down
I had assumed that both codes would find the same answer, but as you have data .. spaces .. data then a different outcome results.. So in this case rinkydink does indeed deserve the credit
fwiw, you can get the same result quickly with a Find (no for points for me pls)
Regards
Dave
Dave, your code selects the cell nicely, but ultimately I want to use 'top' as the top of a Range(top, btm) thing, and I couldn't figure out how to adapt the logic of yours to that. But thanks.
In retrospect I should have phrased the question like this:
"How do I write this line so that it identifies the last cell in Column G that has a value, as opposed to the last cell containing a formula?"
Business Accounts
Answer for Membership
by: jppintoPosted on 2009-10-23 at 14:14:52ID: 25648711
Set top =Range("G4:G" & Cells(Cells.Rows.Count, "G").End(xlUp).Row)