Hide/Unhide

jarhead58

Active Member
Joined
Sep 21, 2017
Messages
364
Office Version
  1. 2021
Platform
  1. Windows
Good morning!!

To start, I understand that columns can be hidden/unhidden via the Format function on the toolbar. What I need to have happen is to use IsDate to search F2:F40 for a date, none particular, but a date. If not, in the row containing the False return, look at the contents in column A, Match it in Sheet2, whatever column it is in, and hide that column. If it does, just fall through and continue. Let me know if I can detail it better than below;

Sheet1

A B C D E F
Text1 11/7/19
Text2x
Text311/7/19
Text411/7/19
Text511/7/19
Text611/7/19

<tbody>
</tbody>


Sheet2

A B C D E F
Text1Text2Text3Text4Text5

<tbody>
</tbody>
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
Code:
Sub jarhead()
    Dim Cl As Range, Fnd As Range
    
    For Each Cl In Range("F2:F40")
        If Not IsDate(Cl.Value) Then
            Set Fnd = Sheets("sheet2").Rows(1).Find(Cl.Offset(, -5).Value, , , xlWhole, , , False, , False)
            If Not Fnd Is Nothing Then Fnd.EntireColumn.Hidden = True
        End If
    Next Cl
End Sub
 
Upvote 0
Good morning!!

To start, I understand that columns can be hidden/unhidden via the Format function on the toolbar. What I need to have happen is to use IsDate to search F2:F40 for a date, none particular, but a date. If not, in the row containing the False return, look at the contents in column A, Match it in Sheet2, whatever column it is in, and hide that column. If it does, just fall through and continue. Let me know if I can detail it better than below;

Sheet1

A B C D E F
Text111/7/19
Text2x
Text311/7/19
Text411/7/19
Text511/7/19
Text611/7/19

<tbody>
</tbody>


Sheet2

A B C D E F
Text1Text2Text3Text4Text5

<tbody>
</tbody>

Please disregard the last post. Can't get the table to copy over to the message!
 
Upvote 0
How about
Code:
Sub jarhead()
    Dim Cl As Range, Fnd As Range
    
    For Each Cl In Range("F2:F40")
        If Not IsDate(Cl.Value) Then
            Set Fnd = Sheets("sheet2").Rows(1).Find(Cl.Offset(, -5).Value, , , xlWhole, , , False, , False)
            If Not Fnd Is Nothing Then Fnd.EntireColumn.Hidden = True
        End If
    Next Cl
End Sub

LOL!

So you actually made sense of it huh?

For future reference, how can I get an excel table to copy into the message, if possible?
 
Upvote 0
Lets see if this works.

Sheet1

Excel 2016 (Windows) 32 bit
A
B
C
D
E
F
1
2
text1
11/7/2019​
3
text2
11/7/2019​
4
text3
no date
5
text4
11/7/2019​
6
text5
11/7/2019​
Sheet: Sheet1


Sheet2

Excel 2016 (Windows) 32 bit
A
B
C
D
E
F
1
text1text2text3text4
2
3
4
5
Sheet: Sheet2
 
Upvote 0
I only want the column that didn't have a date to be hidden on sheet2. Hopefully that clears it up a little lol!
 
Upvote 0
Assuming it was on this line
Code:
Set Fnd = Sheets("[COLOR=#ff0000]sheet2[/COLOR]").Rows(1).Find(Cl.Offset(, -5).Value, , , xlWhole, , , False, , False)
Change the value in red to match your actual sheet name
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

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