VBA to find first visible cell

seguin85

Active Member
Joined
Mar 17, 2015
Messages
278
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I've been looking for a while through numerous threads to find a solution to my problem. Anyways I am grabbing information from another workbook from another department and the cells where I need the information are always changing. I need to be able to select the first visible cell and set my workbook to this cell (it is always a date). This date changes depending on when the information has been updated. The old dates are hidden. So I want a line of code that can help me find this.

This is one of the iterations that I've tried so far...

Range("P4").Select
Do Until UsedRange.SpecialCells(xlCellTypeVisible)
ActiveCell.Offset(0,1).Select
Loop

Any help would be appreciated.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
First cell to be showing. They manually hide all the columns of previously passed dates
 
Upvote 0
I need to be able to select the first visible cell and set my workbook to this cell (it is always a date).
Assuming your dates are in Column A...

Range("A2:A" & Rows.Count).SpecialCells(xlVisible)(1).Select

Change the red 2 to the row number where the first hidden row could possibly be located at. I used 2 because I figured Row 1 would be a header row and header rows are always visible, you it needs to be skipped over. If you have three header rows, then you would change the red 2 to 4 (the first row that could possibly be hidden). I would note, though, that it is rarely necessary to select cells in order to do things with them.
 
Upvote 0
Thanks Rick!!

With a little tweaking I made it work... The columns were hidden not the rows. So I used

Range("P4:ZZ4" & Columns.Count).SpecialCells(xlVisible)(1).Select
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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