Selecting populated cells in a COLUMN - Efficient way - without selecting

1. Selecting populated cells in a COLUMN - Efficient way - without selecting

Hi Excel Forum,

And a happy and prosperous 2021 to you all

You have to excuse the vague title but it was the best way I could explain it.

What I am trying to achieve is to name a range after part of a macro is run. I can do it with selection up but mother always tells me 'Never to select' in a macro as it is bad practice. So there must be a more efficient way which has now got me dumb founded.

I attach a very primitive spreadsheet with the macro in the back and you will see what I am trying to do but below is the code that I jotted up before this post

``Please Login or Register  to view this content.``
As you can see I have located the last cell in the specific column but what to do after that has blown my mind or maybe I am thinking to deep into it as surely it can't be that hard?

Any help would be greatly appreciated

2. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

Try
``Please Login or Register  to view this content.``
``Please Login or Register  to view this content.``

3. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

Maybe a wally mohadin, but do I need to dim the x and if so... as a range?

4. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

Right
``Please Login or Register  to view this content.``
Sorry forget to mention that

5. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

mohadin, you are a genius. Thank you so much.

Can I be a pain but for my own limited knowledge

How does the below 2 X's work?

``Please Login or Register  to view this content.``
What is it actually doing?

6. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

When you set x = Range...
That's mean x is referencing that range
And you deal with it as range
In your case the first date
So x.End(xlup) goes to the last date

Thank you

8. Re: Selecting populated cells in a COLUMN - Efficient way - without selecting

You are welcome
And thank you for the feddback
Be happy

There are currently 1 users browsing this thread. (0 members and 1 guests)