Go To Home

  • Thread starter Thread starter TONYC
  • Start date Start date
T

TONYC

I would like to be able to go to the top of a worksheet after running
macro which has selecting criteria via an autofilter.

I can obvioulsy mannualy enter Ctrl + Home, but I want to include thi
in a macro. Recording this funcion shows a specific cell reference.

Freeze pane is also active so selecting a cell above the autofilte
range does not show data from the top. (I attempted to add Cell 'A4'
as shown below). A command for Ctrl + Home would be much bettter. I
this possible?

This is my macro...


Sub EnterDept()

Range("C3").Value = InputBox("Please Enter Business Unit", "Al
Risks")
Selection.AutoFilter Field:=1, Criteria1:=Range("C3").Value
If Range("C3") = "" Then ActiveSheet.ShowAllData
Range("A4").Select
End Su
 
Tony,

Use Application.Goto. E.g.,

Application.Goto Range("A1"), True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Sub EnterDept()
Dim lRow as Long
Dim lCol as Long
Range("C3").Value = InputBox("Please Enter Business Unit", _
"All Risks")
Selection.AutoFilter Field:=1, Criteria1:=Range("C3").Value
If Range("C3") = "" Then ActiveSheet.ShowAllData
lRow = ActiveWindow.SplitRow +1
lCol = ActiveWindow.splitColumn +1
Application.Goto Cells(lRow,lCol)
End Sub

If you just want to go to the top left of your Autofilter

Sub EnterDept()
Range("C3").Value = InputBox("Please Enter Business Unit", _
"All Risks")
Selection.AutoFilter Field:=1, Criteria1:=Range("C3").Value
If Range("C3") = "" Then ActiveSheet.ShowAllData
Application.Goto Activesheet.Autofilter.Range(1)
End Sub
 
I have tried this but it still dosent take me to the first record belo
the freeze pane line.

Ton
 
Would any ideas here help?

Sub Demo()
If ActiveWindow.FreezePanes Then
With ActiveWindow.ActivePane
Application.Goto Cells(.ScrollRow, .ScrollColumn)
End With
End If
End Sub

HTH
Dana DeLouis
 
That goes to the upper left cell in the current visible area. As long as A4
was that cell, it would work, but it appeared to me he wanted the cell
immediately below the frozen area when there are no hidden rows.

You have to read the thread to get that context.

Just my opinion of course.
 
Thank you all for your response. After adding the following line to th
macro, it did appear to work to my satisfaction.

Application.Goto Range("A1"), True

Ton
 
Glad you are happy, but to be precise, that isn't the equipvalent to
Ctrl+Home in the situation you describe and in response to that suggestion,
you said:
 

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