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>
 
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

That's the name I use just a test workbook. I'll implement it once I get it working.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Was it that line of code that gave the Run time error 9 Subscript out of range error?
 
Upvote 0
In that case there is no sheet called "Sheet2" in the active workbook when you ran the code.
 
Upvote 0
In that case there is no sheet called "Sheet2" in the active workbook when you ran the code.

Well that was a duh moment!! Evidently, the add-in I used to post, brought up a module that covered my existing module. I was pasting it into a different WB module. Ok, it has one hiccup and it may just be the way I communicated it. The column that I need hid is the matching sheet2 column; sheet1 text3(A4) to sheet2 column(D), so column(D) would be hidden. It hid column(F) text5 for some reason.
 
Upvote 0
With data like


Book1
ABCDEF
2Text111/07/2019
3Text212/07/2019
4Text3x
5Text411/07/2019
6Text511/07/2019
7Text611/07/2019
Sheet1


I get


Book1
ABDEF
1Text1Text2Text4Text5Text6
Sheet2


If you are getting something different, check you data is correct & that your dates are real dates, not text
 
Upvote 0
With data like

ABCDEF
2Text111/07/2019
3Text212/07/2019
4Text3x
5Text411/07/2019
6Text511/07/2019
7Text611/07/2019

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



I get

ABDEF
1Text1Text2Text4Text5Text6

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2



If you are getting something different, check you data is correct & that your dates are real dates, not text

Evidently it didn't like me just running the module. I reset the columns, saved the WB and then reopened it. It got the right column but also hid col(F) thru (AM)!
 
Upvote 0
That's because F5 to F40 were not a date.
If you want to limit it to the used range try
Code:
    For Each Cl In Range("F2", Range("F" & Rows.Count).End(xlUp))
 
Upvote 0
That's because F5 to F40 were not a date.
If you want to limit it to the used range try
Code:
    For Each Cl In Range("F2", Range("F" & Rows.Count).End(xlUp))

Ah, gotcha, makes sense to this knucklehead lol!! Works fine! I really appreciate all of the help Fluff!!
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,286
Members
449,218
Latest member
Excel Master

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