Finding a number in a row based on a Week number and unhiding the column it appears in

LemonyMidget

New Member
Joined
Sep 14, 2016
Messages
4
So I've been trying and failing for days at trying to work this out.

Basically I need the code to look at the Headlines tab and reference E7 (Weeknumber) and find that week number in Row 46 on the 'Part' tab, and unhide the column that has the weknumber in row 46..

Please someone help :(
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Are your Columns A=Week1 B=Week2 ...

And also, just to confirm if the above is correct that you have 52 columns hidden and you want to unhide one depending on what is in the Headlines tab Cell E7?
 
Upvote 0
If that is correct, try the following;

Code:
Sub UnhideWeek()

'Selects the week number to look up
Weekno = Sheets("Headlines").Cells(7, 5).Value

'Unhides columns to find the column that is required
Sheets("Part").Activate
    Columns("A:AZ").Select
    Selection.EntireColumn.Hidden = False
    Rows("46:46").Select
    Selection.Find(What:=Weekno, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
   Weekcol = ActiveCell.Column
    
'Rehides columns
    Columns("A:AZ").EntireColumn.Hidden = True
'Unhides Week required
    Columns(Weekcol).EntireColumn.Hidden = False
    Cells(1, 1).Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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