Programming equiv. of <Ctrl> <Home>

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On a sheet, executing <Ctrl> <Home> moves the cursor to the top/left corner
of the "unfrozen" window (not just the displayed window) regardless of
horiz/vert scroll positions.

Anyone know how to code the same movement?
 
On a sheet, executing <Ctrl> <Home> moves the cursor to the top/left corner
of the "unfrozen" window (not just the displayed window) regardless of
horiz/vert scroll positions.

Anyone know how to code the same movement?
Don't know if this will help, but what happens if you turn on the macro
recorder (Tools | Macro > Record new macro...) and use the UI to carry
out a CTRL HOME?

Remember to turn off the recorder.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Sub CtrlHome()
Application.Goto Range("A1"), True
ActiveWindow.VisibleRange(1, 1).Select
End Sub
 
Tushar,

I appreciate your response but using the macro recorder does not work
because it creates a hard coded cell reference... This fails if the macro
"hides" that particular column on a subsequent running.
 
I guess I shouldn't have doubted you. I did not think this would do what the
OP was requesting as I thought it would goto cell A1. But I tested it and
sure enough it did work.
 
Tom,

Thanks... Your suggestion has me about 95%+ there but...

As written, this does in fact take me to the top/left of the "unfrozen"
window but, unlike the <Ctrl><Home> keystroke combo does not take into acount
hidden columns (e.g. top/left of unfrozen area is D11 but macro has columns D
thru G hidden; <Ctrl><Home> goes to H11 but code goes to D11)

Any thoughts?

-Carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top