VBA req'd so double-clicking cell A1 will perform Control+End keyboard shortcut

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hello

I'm new to VBA and I wondered if it would be possible for a few lines of VBA so when I double click cell A1 in a specific sheet then it will jump to the bottom of the sheet i.e. the same as performing the Control+End keyboard shortcut.

Many thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Maybe this way...pasted in the worksheet module

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("A1").SpecialCells(xlCellTypeLastCell).Select
End If
End Sub
 
Upvote 0
Many thanks Michael!

Although it works, it's also scrolling across to column G, which is the first empty column - would you be kind enough to amend your code to it scrolls directly down to Column A please?

Thanks again!

P.S. Apologies, I've just realised that that is what Ctrl+End does, but it's not quite what I wanted.
 
Last edited:
Upvote 0
OK, but your request was to replicate CTRL + End, which my code does.
To get the last used row in the column, use
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Select
End If
End Sub
 
Upvote 0
Yes, I just realised that, as per the PS.

Thanks ever so much Michael, it's perfect now!
 
Upvote 0
Just a minor suggestion ..
Since it is not possible to double-click more than 1 cell at a time, there is really no need to go through the 'Not Intersect' process - you can be more direct.
Rich (BB code):
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target.Address = "$A$1" Then
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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