Selecting Cell ignoring Hidden Cells

SanjayGMusafir

Well-known Member
Joined
Sep 7, 2018
Messages
1,462
Office Version
  1. 2021
Platform
  1. MacOS
Hi Experts,

I have many worksheet(s) with hidden rows.

Now, I need a vba that may help me do following -

  • Select table rows, from Second Row below the Hidden Rows till the Bottom of the Table
  • And then, Sort them in Ascending Oder. All such tables start from Column A of the worksheet only.
  • Actually I want a general code that I may be able to use with any worksheet/table I want.
When I use "Record Macro" method, it uses specific cell addresses, worksheet & table names. Thus it becomes useless once I hide few more rows. Further, it can't be used on any other worksheet/table.

Please Help

Thanks a lot ?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Experts
I am able to write this code, picking ides from various sources. Working fine with me.

Certainly it's a novice's work.

Can we improve this coding, or if there is a better way of getting the intended result.

Please help

Thanks a lot ��

Rich (BB code):
Sub GoHm()
'
' GoHm
'


'
    Dim rngData As Range
    Dim rngKey As Range
    
    'To Select firt visible cell after hidden rows in Frozen Pane
    With ActiveSheet
    
    With Range(.Cells(1, 1), .UsedRange)
    
        With .Offset(ActiveWindow.SplitRow, ActiveWindow.SplitColumn).SpecialCells(xlCellTypeVisible)
            .Cells(2, 1).Select
        End With
        
    End With
    
    End With
    
    'To Reach first cell of the selected row
    Selection.End(xlToLeft).Select
    Selection.End(xlToLeft).Select
    
    'To set First cell of the Range to be sorted
    Set rngKey = Selection
    
    'To select range to sort
    Range(Selection, Selection.End(xlDown)).Select
    
    'The range to be sorted
    Set rngData = Selection
    
    'To sort cells in ascending order
    rngData.Sort Key1:=rngKey, Order1:=xlAscending, Header:=xlYes
    
    ActiveWorkbook.Save
    
End Sub


Hi Experts,

I have many worksheet(s) with hidden rows.

Now, I need a vba that may help me do following -

  • Select table rows, from Second Row below the Hidden Rows till the Bottom of the Table
  • And then, Sort them in Ascending Oder. All such tables start from Column A of the worksheet only.
  • Actually I want a general code that I may be able to use with any worksheet/table I want.
When I use "Record Macro" method, it uses specific cell addresses, worksheet & table names. Thus it becomes useless once I hide few more rows. Further, it can't be used on any other worksheet/table.

Please Help

Thanks a lot 
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,107
Members
449,205
Latest member
ralemanygarcia

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