Hide/Unhide

jarhead58

Active Member
Joined
Sep 21, 2017
Messages
367
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
[TABLE="width: 300, align: center"]
<tbody>[TR]
[TD]Text1 [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]11/7/19[/TD]
[/TR]
[TR]
[TD]Text2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]Text3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/7/19[/TD]
[/TR]
[TR]
[TD]Text4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/7/19[/TD]
[/TR]
[TR]
[TD]Text5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/7/19[/TD]
[/TR]
[TR]
[TD]Text6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/7/19[/TD]
[/TR]
</tbody>[/TABLE]


Sheet2

A B C D E F [TABLE="width: 300, align: center"]
<tbody>[TR]
[TD] [/TD]
[TD]Text1[/TD]
[TD]Text2[/TD]
[TD]Text3[/TD]
[TD]Text4[/TD]
[TD]Text5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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
Text1
Text2
Text3x
Text4
Text5
Text6

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]2[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]11/07/2019[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]12/07/2019[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]11/07/2019[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]11/07/2019[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]11/07/2019[/TD]

</tbody>
Sheet1



I get

ABDEF
Text1Text2Text4Text5Text6

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

</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,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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