Question on Selection in vba

HunterN

Active Member
Joined
Mar 19, 2002
Messages
479
Hi,

I am wondering if there is a way using VBA, to change from having many
rows selected to only having the last row that is in the current selection?

For instance if there are five rows selected in column C, I want the next
vba code to be one that only activates the last row in that selection.

Thanks much,
Nancy
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about:

Code:
Cells(Rows.Count, "C").End(xlUp).Select

But there's usually no need to select. ;)

HTH,

Smitty
 
Upvote 0
Hi HunterN

This statement will select the last cell in the first column of the currently selected range

Code:
Selection.Cells(Selection.Rows.Count, 1).Select

Remark: I'm 100% with Smitty. In most cases it's bad programming practice to select.

Hope this helps
PGC
 
Upvote 0
Hi, guys,

from having many rows selected to only having the last row that is in the current selection
my interpretation is different
Code:
Sub test()
    With Selection
    .Resize(1).Offset(.Rows.Count - 1, 0).Select
    End With
End Sub
of course, talking with pgc01 and Pennysaver, usually you don't need to select

kind regards,
Erik
 
Upvote 0
Thanks, that's what I needed.

I know I shouldn't select things, but in this case I needed to.

:)
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

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