Select all written cells starting from C4 until the last available cell in the same column C

Klash Ville

Board Regular
Joined
Sep 19, 2017
Messages
83
Hello everyone,

I have a very simple problem:

How do I select all written cells starting from C4 until the last available cell in that same column C?
 
Last edited:
Helps if I put my brain in gear, before posting!
Code:
    Dim Rng As Range
    
    Set Rng = Range(ActiveCell.Address, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
    Union(Rng.SpecialCells(xlCellTypeConstants), Rng.SpecialCells(xlCellTypeFormulas)).Select
One word of warning. This will only work if you have both Constants & formulae in the column
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Ok, so I fixed the part that it wasn't counting blank cells and written cells within a specific range by modifying your original code into this:

Code:
Dim Rng As Range    
Set Rng = Range("L4", Range("L" & Rows.Count).End(xlUp))
Union(Rng.SpecialCells(xlCellTypeConstants), Rng.SpecialCells(xlCellTypeVisible)).Select
    
MsgBox Rng.Rows.Count

Although, I need to know how to convert that L4 and L into the ActiveCell... which is the only missing thing
 
Upvote 0
Helps if I put my brain in gear, before posting!
Code:
    Dim Rng As Range
    
    Set Rng = Range(ActiveCell.Address, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
    Union(Rng.SpecialCells(xlCellTypeConstants), Rng.SpecialCells(xlCellTypeFormulas)).Select
One word of warning. This will only work if you have both Constants & formulae in the column

And everything is working properly now. Thank you very much @Fluff =)

this is the final result that I have that will be applied into multiple shunks of code, this is perfect, thank you for your assistance

Code:
Dim Rng As Range
    
Set Rng = Range(ActiveCell.Address, Cells(Rows.Count, ActiveCell.Column).End(xlUp))
Union(Rng.SpecialCells(xlCellTypeConstants), Rng.SpecialCells(xlCellTypeVisible)).Select
    
MsgBox Rng.Rows.Count
 
Last edited:
Upvote 0
The code you have posted above is going to select all the blanks cells (unless they've been hidden). Is that what you want?
In post#5 you said that Weeble' code did not do what you want, but it will give the same result as your code above!
 
Upvote 0
The code you have posted above is going to select all the blanks cells (unless they've been hidden). Is that what you want?
In post#5 you said that Weeble' code did not do what you want, but it will give the same result as your code above!

Do not worry, I have tested my version of your code mixed with your ActiveCell solution, and it works flawlessly. It selects all written and blank cells until the last written cell in that same target column only. It's perfect and exacly what I needed =)

Yes, Weeble's code has the same result had the original that I have initially used. I posted it anyways to give a base idea of what I tried, but anyways =)
 
Upvote 0
As long as you're happy that's fine:)

I just noticed that the current code works 100% with cells with text.

Although when it comes to cells with numbers, I replaced:

Code:
[COLOR=#333333][FONT=&quot]xlCellTypeConstants[/FONT][/COLOR]

to:

Code:
[COLOR=#333333][FONT=&quot]xlCellTypeFormulas[/FONT][/COLOR]

Since all those numbers come from formulas, it works flawlessy. Although, do you know a way to direcly detect numbers?
 
Upvote 0
BUMP to my last reply:

Code:
[COLOR=#333333]xlCellTypeFormulas
[/COLOR][/COLOR]
Since all those numbers come from formulas, it works flawlessy. Although, do you know a way to direcly detect numbers?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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