Extend Selection from the Active cell to last Row i.e Non Blank cell in the same Column (having few blank cells )

shoun2502

New Member
Joined
Nov 14, 2018
Messages
45
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi ,
Actually I was trying to run the subroutine to select a Single Column from the Active cell and Drag the selection to the Last Row (The Single Column and Multiple Rows are having some blank cells which are to be skipped). The code below doesn't give the desired result

I would appreciate if anyone could help to run the subroutine to select the same from the Active Cell

I have tried the below code but it is not giving the desired result.

VBA Code:
Sub MyLastRowSamecolumn()
    Dim myCurrentColumn As Long
    Dim myLastRow As Long
    myCurrentColumn = ActiveCell.Column
    myLastRow = Cells.Find(What:="*", After:=Cells(1, 1), _
                        Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious, MatchCase:=False).Column
    Range(ActiveCell, Cells(myCurrentColumn, myLastRow)).Select
End Sub

Thanks in anticipation
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this:
VBA Code:
Sub MyLastRowSamecolumn()
Dim c As Range
    Set c = Columns(ActiveCell.Column).Find(What:="*", _
                        Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious, MatchCase:=False)
    Range(ActiveCell, c).Select
End Sub
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0
Hi akuini.

I was wondering If the same could be done with applying a formula(sum, subtotal) for the single column having values.

Please help me if its possible.

Thanks again
 
Upvote 0
Sorry, my knowledge of excel formula is very basic, so I hope other members can help you.
I also don't understand what you mean.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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