ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Unhide MulipleRows if Cell B10 has a "X" otherwise hide c (https://www.excelbanter.com/excel-programming/426311-macro-unhide-muliplerows-if-cell-b10-has-x-otherwise-hide-c.html)

Leiprecht

Macro to Unhide MulipleRows if Cell B10 has a "X" otherwise hide c
 
Trying to create a macro where if Cell B10 or B11 has an "X" then Rows 15-19
are unhiden. If B10 and B11 are both blank then rows 15-19 is hidden.

Per Jessen

Macro to Unhide MulipleRows if Cell B10 has a "X" otherwise hide c
 
Hi

Try this:

Sub aaa()
If Range("B10").Value = "X" Or Range("B11").Value = "X" Then
Rows("15:19").Hidden = False
Else
Rows("15:19").Hidden = True
End If
End Sub

Regards,
Per

"Leiprecht" skrev i meddelelsen
...
Trying to create a macro where if Cell B10 or B11 has an "X" then Rows
15-19
are unhiden. If B10 and B11 are both blank then rows 15-19 is hidden.



Leiprecht

Macro to Unhide MulipleRows if Cell B10 has a "X" otherwise hi
 
That works! How can i get it to automatically do everytime the cell is
changed?

"Per Jessen" wrote:

Hi

Try this:

Sub aaa()
If Range("B10").Value = "X" Or Range("B11").Value = "X" Then
Rows("15:19").Hidden = False
Else
Rows("15:19").Hidden = True
End If
End Sub

Regards,
Per

"Leiprecht" skrev i meddelelsen
...
Trying to create a macro where if Cell B10 or B11 has an "X" then Rows
15-19
are unhiden. If B10 and B11 are both blank then rows 15-19 is hidden.




Mike H

Macro to Unhide MulipleRows if Cell B10 has a "X" otherwise hide c
 
Hi,

Right click your sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
If UCase(Range("B10")) = "X" Or UCase(Range("B11")) = "X" Then
Rows(15 & ":" & 19).EntireRow.Hidden = False
ElseIf WorksheetFunction.CountA(Range("B10:B11")) = 0 Then
Rows(15 & ":" & 19).EntireRow.Hidden = True
End If
End Sub

Mike

"Leiprecht" wrote:

Trying to create a macro where if Cell B10 or B11 has an "X" then Rows 15-19
are unhiden. If B10 and B11 are both blank then rows 15-19 is hidden.



All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com