Help with worksheet_change checking several cells and performing several actions across sheets.

Devastathor

New Member
Joined
May 13, 2019
Messages
1
So I'm really new to VBA and have been looking everywhere for a solution to my problem. Here's what I've come up with this far.
I'm sure there's a much easier way to do it, but since every section is for a different sheet and each sheet will be different on a day to day basis I don't see how.

Basically Z2,3,4 is the production orders for monday on a production line. Z5,6,7 is for tuesday and so on monday to friday.
Z17,18,19 is production orders for monday on another production line, Z20,21,22 tuesday and so on monday to friday.
So I have to repeat this macro for each day of the week, on each production line.

Thing is, the amount of orders for each day can vary from 1 to 3, so I want to hide some parts of the sheets depending on wether or not there is 1, 2 or 3 production orders on that particular day.
I've also chosen to hide the sheet alltogether if there's no production orders on that day. This code is placed in the sheet where the production data for the following week is imported.

Am I on to something here or do I have to do it another way?

Any thoughts or help appreciated. :)



Private Sub Worksheet_Change(ByVal Target As Range)


Sheets("Skjema Man L2").Rows("1:321").EntireRow.Hidden = False


If [Z2] = 0 Then
Sheets("Skjema Man L2").Visible = False
Else
Sheets("Skjema Man L2").Visible = True
End If


If [Z3] = 0 Then
Sheets("Skjema Man L2").Rows("112:321").EntireRow.Hidden = True
ElseIf [Z4] = 0 Then
Sheets("Skjema Man L2").Rows("217:321").EntireRow.Hidden = True
End If


Sheets("Skjema Man L3").Rows("1:321").EntireRow.Hidden = False


If [Z17] = 0 Then
Sheets("Skjema Man L3").Visible = False
Else
Sheets("Skjema Man L3").Visible = True
End If


If [Z18] = 0 Then
Sheets("Skjema Man L3").Rows("112:321").EntireRow.Hidden = True
ElseIf [Z19] = 0 Then
Sheets("Skjema Man L3").Rows("217:321").EntireRow.Hidden = True
End If


End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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