Hello, i have the following code i want to use for a button. It will random;y work like sometime when i open the sheet but then i start getting error codes like <style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Helvetica Neue'} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Helvetica Neue'; min-height: 12.0px} </style>
Run-time error '1004':
Unable to set the Hidden property of the Range class
and it debugs on this
<style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 ; background-color: #ffffff } p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff ; min-height: 13.0px} span.s1 {color: #011993 } </style>
Sub UnHideBlankDays()
If Range("B9") = "" Then
Rows("7:23").EntireRow.Hidden = False
End If
But other times it would work just fine.
My code is long and I also have another one just like this with True values on everything assigned to another bottom to hide all the rows.
<style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 ; background-color: #ffffff } p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff ; min-height: 13.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993 ; background-color: #ffffff } span.s1 {color: #011993 } span.s2 {color: #000000 } </style>
Sub UnHideBlankDays()
If Range("B9") = "" Then
Rows("7:23").EntireRow.Hidden = False
End If
If Range("B26") = "" Then
Rows("24:40").EntireRow.Hidden = False
End If
If Range("B43") = "" Then
Rows("41:57").EntireRow.Hidden = False
End If
If Range("B60") = "" Then
Rows("58:74").EntireRow.Hidden = False
End If
If Range("B77") = "" Then
Rows("75:91").EntireRow.Hidden = False
End If
If Range("B94") = "" Then
Rows("92:108").EntireRow.Hidden = False
End If
If Range("B111") = "" Then
Rows("109:125").EntireRow.Hidden = False
End If
If Range("B128") = "" Then
Rows("126:142").EntireRow.Hidden = False
End If
If Range("B145") = "" Then
Rows("143:159").EntireRow.Hidden = False
End If
If Range("B162") = "" Then
Rows("160:176").EntireRow.Hidden = False
End If
If Range("B179") = "" Then
Rows("177:193").EntireRow.Hidden = False
End If
If Range("B196") = "" Then
Rows("194:209").EntireRow.Hidden = False
End If
If Range("B213") = "" Then
Rows("211:227").EntireRow.Hidden = False
End If
If Range("B230") = "" Then
Rows("228:244").EntireRow.Hidden = False
End If
If Range("B247") = "" Then
Rows("245:261").EntireRow.Hidden = False
End If
If Range("B264") = "" Then
Rows("262:278").EntireRow.Hidden = False
End If
If Range("B281") = "" Then
Rows("279:295").EntireRow.Hidden = False
End If
If Range("B298") = "" Then
Rows("296:312").EntireRow.Hidden = False
End If
If Range("B315") = "" Then
Rows("313:329").EntireRow.Hidden = False
End If
If Range("B332") = "" Then
Rows("330:346").EntireRow.Hidden = False
End If
If Range("B349") = "" Then
Rows("347:363").EntireRow.Hidden = False
End If
If Range("B366") = "" Then
Rows("364:380").EntireRow.Hidden = False
End If
If Range("B383") = "" Then
Rows("381:397").EntireRow.Hidden = False
End If
If Range("B400") = "" Then
Rows("398:414").EntireRow.Hidden = False
End If
If Range("B417") = "" Then
Rows("415:431").EntireRow.Hidden = False
End If
If Range("B434") = "" Then
Rows("432:448").EntireRow.Hidden = False
End If
If Range("B451") = "" Then
Rows("449:465").EntireRow.Hidden = False
End If
If Range("B468") = "" Then
Rows("466:482").EntireRow.Hidden = False
End If
If Range("B485") = "" Then
Rows("483:499").EntireRow.Hidden = False
End If
If Range("B502") = "" Then
Rows("500:516").EntireRow.Hidden = False
End If
If Range("B519") = "" Then
Rows("517:533").EntireRow.Hidden = False
End If
If Range("B536") = "" Then
Rows("534:550").EntireRow.Hidden = False
End If
If Range("B553") = "" Then
Rows("551:567").EntireRow.Hidden = False
End If
If Range("B570") = "" Then
Rows("568:584").EntireRow.Hidden = False
End If
If Range("B587") = "" Then
Rows("585:601").EntireRow.Hidden = False
End If
If Range("B604") = "" Then
Rows("602:618").EntireRow.Hidden = False
End If
If Range("B621") = "" Then
Rows("619:635").EntireRow.Hidden = False
End If
If Range("B638") = "" Then
Rows("636:652").EntireRow.Hidden = False
End If
If Range("B655") = "" Then
Rows("653:669").EntireRow.Hidden = False
End If
If Range("B672") = "" Then
Rows("670:686").EntireRow.Hidden = False
End If
If Range("B689") = "" Then
Rows("687:703").EntireRow.Hidden = False
End If
If Range("B706") = "" Then
Rows("704:720").EntireRow.Hidden = False
End If
If Range("B723") = "" Then
Rows("721:737").EntireRow.Hidden = False
End If
If Range("B740") = "" Then
Rows("738:754").EntireRow.Hidden = False
End If
If Range("B757") = "" Then
Rows("755:771").EntireRow.Hidden = False
End If
If Range("B774") = "" Then
Rows("772:788").EntireRow.Hidden = False
End If
If Range("B791") = "" Then
Rows("789:805").EntireRow.Hidden = False
End If
If Range("B808") = "" Then
Rows("806:822").EntireRow.Hidden = False
End If
If Range("B825") = "" Then
Rows("823:839").EntireRow.Hidden = False
End If
If Range("B842") = "" Then
Rows("840:856").EntireRow.Hidden = False
End If
If Range("B859") = "" Then
Rows("857:873").EntireRow.Hidden = False
End If
If Range("B876") = "" Then
Rows("874:890").EntireRow.Hidden = False
End If
If Range("B893") = "" Then
Rows("891:907").EntireRow.Hidden = False
End If
If Range("B910") = "" Then
Rows("908:924").EntireRow.Hidden = False
End If
If Range("B927") = "" Then
Rows("925:941").EntireRow.Hidden = False
End If
If Range("B944") = "" Then
Rows("942:958").EntireRow.Hidden = False
End If
If Range("B961") = "" Then
Rows("959:975").EntireRow.Hidden = False
End If
If Range("B978") = "" Then
Rows("976:992").EntireRow.Hidden = False
End If
If Range("B995") = "" Then
Rows("993:1009").EntireRow.Hidden = False
End If
If Range("B1012") = "" Then
Rows("1010:1026").EntireRow.Hidden = False
End If
End Sub
Run-time error '1004':
Unable to set the Hidden property of the Range class
and it debugs on this
<style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 ; background-color: #ffffff } p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff ; min-height: 13.0px} span.s1 {color: #011993 } </style>
Sub UnHideBlankDays()
If Range("B9") = "" Then
Rows("7:23").EntireRow.Hidden = False
End If
But other times it would work just fine.
My code is long and I also have another one just like this with True values on everything assigned to another bottom to hide all the rows.
<style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 ; background-color: #ffffff } p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff ; min-height: 13.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993 ; background-color: #ffffff } span.s1 {color: #011993 } span.s2 {color: #000000 } </style>
Sub UnHideBlankDays()
If Range("B9") = "" Then
Rows("7:23").EntireRow.Hidden = False
End If
If Range("B26") = "" Then
Rows("24:40").EntireRow.Hidden = False
End If
If Range("B43") = "" Then
Rows("41:57").EntireRow.Hidden = False
End If
If Range("B60") = "" Then
Rows("58:74").EntireRow.Hidden = False
End If
If Range("B77") = "" Then
Rows("75:91").EntireRow.Hidden = False
End If
If Range("B94") = "" Then
Rows("92:108").EntireRow.Hidden = False
End If
If Range("B111") = "" Then
Rows("109:125").EntireRow.Hidden = False
End If
If Range("B128") = "" Then
Rows("126:142").EntireRow.Hidden = False
End If
If Range("B145") = "" Then
Rows("143:159").EntireRow.Hidden = False
End If
If Range("B162") = "" Then
Rows("160:176").EntireRow.Hidden = False
End If
If Range("B179") = "" Then
Rows("177:193").EntireRow.Hidden = False
End If
If Range("B196") = "" Then
Rows("194:209").EntireRow.Hidden = False
End If
If Range("B213") = "" Then
Rows("211:227").EntireRow.Hidden = False
End If
If Range("B230") = "" Then
Rows("228:244").EntireRow.Hidden = False
End If
If Range("B247") = "" Then
Rows("245:261").EntireRow.Hidden = False
End If
If Range("B264") = "" Then
Rows("262:278").EntireRow.Hidden = False
End If
If Range("B281") = "" Then
Rows("279:295").EntireRow.Hidden = False
End If
If Range("B298") = "" Then
Rows("296:312").EntireRow.Hidden = False
End If
If Range("B315") = "" Then
Rows("313:329").EntireRow.Hidden = False
End If
If Range("B332") = "" Then
Rows("330:346").EntireRow.Hidden = False
End If
If Range("B349") = "" Then
Rows("347:363").EntireRow.Hidden = False
End If
If Range("B366") = "" Then
Rows("364:380").EntireRow.Hidden = False
End If
If Range("B383") = "" Then
Rows("381:397").EntireRow.Hidden = False
End If
If Range("B400") = "" Then
Rows("398:414").EntireRow.Hidden = False
End If
If Range("B417") = "" Then
Rows("415:431").EntireRow.Hidden = False
End If
If Range("B434") = "" Then
Rows("432:448").EntireRow.Hidden = False
End If
If Range("B451") = "" Then
Rows("449:465").EntireRow.Hidden = False
End If
If Range("B468") = "" Then
Rows("466:482").EntireRow.Hidden = False
End If
If Range("B485") = "" Then
Rows("483:499").EntireRow.Hidden = False
End If
If Range("B502") = "" Then
Rows("500:516").EntireRow.Hidden = False
End If
If Range("B519") = "" Then
Rows("517:533").EntireRow.Hidden = False
End If
If Range("B536") = "" Then
Rows("534:550").EntireRow.Hidden = False
End If
If Range("B553") = "" Then
Rows("551:567").EntireRow.Hidden = False
End If
If Range("B570") = "" Then
Rows("568:584").EntireRow.Hidden = False
End If
If Range("B587") = "" Then
Rows("585:601").EntireRow.Hidden = False
End If
If Range("B604") = "" Then
Rows("602:618").EntireRow.Hidden = False
End If
If Range("B621") = "" Then
Rows("619:635").EntireRow.Hidden = False
End If
If Range("B638") = "" Then
Rows("636:652").EntireRow.Hidden = False
End If
If Range("B655") = "" Then
Rows("653:669").EntireRow.Hidden = False
End If
If Range("B672") = "" Then
Rows("670:686").EntireRow.Hidden = False
End If
If Range("B689") = "" Then
Rows("687:703").EntireRow.Hidden = False
End If
If Range("B706") = "" Then
Rows("704:720").EntireRow.Hidden = False
End If
If Range("B723") = "" Then
Rows("721:737").EntireRow.Hidden = False
End If
If Range("B740") = "" Then
Rows("738:754").EntireRow.Hidden = False
End If
If Range("B757") = "" Then
Rows("755:771").EntireRow.Hidden = False
End If
If Range("B774") = "" Then
Rows("772:788").EntireRow.Hidden = False
End If
If Range("B791") = "" Then
Rows("789:805").EntireRow.Hidden = False
End If
If Range("B808") = "" Then
Rows("806:822").EntireRow.Hidden = False
End If
If Range("B825") = "" Then
Rows("823:839").EntireRow.Hidden = False
End If
If Range("B842") = "" Then
Rows("840:856").EntireRow.Hidden = False
End If
If Range("B859") = "" Then
Rows("857:873").EntireRow.Hidden = False
End If
If Range("B876") = "" Then
Rows("874:890").EntireRow.Hidden = False
End If
If Range("B893") = "" Then
Rows("891:907").EntireRow.Hidden = False
End If
If Range("B910") = "" Then
Rows("908:924").EntireRow.Hidden = False
End If
If Range("B927") = "" Then
Rows("925:941").EntireRow.Hidden = False
End If
If Range("B944") = "" Then
Rows("942:958").EntireRow.Hidden = False
End If
If Range("B961") = "" Then
Rows("959:975").EntireRow.Hidden = False
End If
If Range("B978") = "" Then
Rows("976:992").EntireRow.Hidden = False
End If
If Range("B995") = "" Then
Rows("993:1009").EntireRow.Hidden = False
End If
If Range("B1012") = "" Then
Rows("1010:1026").EntireRow.Hidden = False
End If
End Sub