ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Hide Rows (https://www.excelbanter.com/excel-programming/410937-macro-hide-rows.html)

New2Macros

Macro to Hide Rows
 
I'm using the following macro to hide/show rows, but I get a "run-time error
'1004' Unable to set the Hidden property of the Range Class" if the row
contains a combo box. The combo boxes are inserting information into
adjoining cells on the same row. What could be causing the error?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Range("2:" & Rows.Count).EntireRow.Hidden = False
Range(CStr(3 + 2 * Range("A2").Value) & ":" & _
Rows.Count).EntireRow.Hidden = True
End If
End Sub

Susan

Macro to Hide Rows
 
the error is that there's a combobox in the way & it won't let you
programatically hide the row. there's nothing wrong with the sub
(that i can see).
you'll have to skip the row if it contains a combobox.
hth
susan


On May 14, 9:51*am, New2Macros
wrote:
I'm using the following macro to hide/show rows, but I get a "run-time error
'1004' Unable to set the Hidden property of the Range Class" if the row
contains a combo box. *The combo boxes are inserting information into
adjoining cells on the same row. *What could be causing the error?

Private Sub Worksheet_Change(ByVal Target As Range)
* *If Target.Address = "$A$2" Then
* * *Range("2:" & Rows.Count).EntireRow.Hidden = False
* * *Range(CStr(3 + 2 * Range("A2").Value) & ":" & _
* * * * * * *Rows.Count).EntireRow.Hidden = True
* *End If
*End Sub



New2Macros

Macro to Hide Rows
 
That will cause a problem, because I need a combo box on every row. Is there
a way to get around this?


"Susan" wrote:

the error is that there's a combobox in the way & it won't let you
programatically hide the row. there's nothing wrong with the sub
(that i can see).
you'll have to skip the row if it contains a combobox.
hth
susan


On May 14, 9:51 am, New2Macros
wrote:
I'm using the following macro to hide/show rows, but I get a "run-time error
'1004' Unable to set the Hidden property of the Range Class" if the row
contains a combo box. The combo boxes are inserting information into
adjoining cells on the same row. What could be causing the error?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Range("2:" & Rows.Count).EntireRow.Hidden = False
Range(CStr(3 + 2 * Range("A2").Value) & ":" & _
Rows.Count).EntireRow.Hidden = True
End If
End Sub




Susan

Macro to Hide Rows with ComboBoxes
 
i don't know; maybe someone else can help.
susan

On May 14, 11:45*am, New2Macros
wrote:
That will cause a problem, because I need a combo box on every row. *Is there
a way to get around this?



"Susan" wrote:
the error is that there's a combobox in the way & it won't let you
programatically hide the row. *there's nothing wrong with the sub
(that i can see).
you'll have to skip the row if it contains a combobox.
hth
susan


On May 14, 9:51 am, New2Macros
wrote:
I'm using the following macro to hide/show rows, but I get a "run-time error
'1004' Unable to set the Hidden property of the Range Class" if the row
contains a combo box. *The combo boxes are inserting information into
adjoining cells on the same row. *What could be causing the error?


Private Sub Worksheet_Change(ByVal Target As Range)
* *If Target.Address = "$A$2" Then
* * *Range("2:" & Rows.Count).EntireRow.Hidden = False
* * *Range(CStr(3 + 2 * Range("A2").Value) & ":" & _
* * * * * * *Rows.Count).EntireRow.Hidden = True
* *End If
*End Sub- Hide quoted text -


- Show quoted text -



New2Macros

Macro to Hide Rows with ComboBoxes
 
Okay, who could help?

"Susan" wrote:

i don't know; maybe someone else can help.
susan

On May 14, 11:45 am, New2Macros
wrote:
That will cause a problem, because I need a combo box on every row. Is there
a way to get around this?



"Susan" wrote:
the error is that there's a combobox in the way & it won't let you
programatically hide the row. there's nothing wrong with the sub
(that i can see).
you'll have to skip the row if it contains a combobox.
hth
susan


On May 14, 9:51 am, New2Macros
wrote:
I'm using the following macro to hide/show rows, but I get a "run-time error
'1004' Unable to set the Hidden property of the Range Class" if the row
contains a combo box. The combo boxes are inserting information into
adjoining cells on the same row. What could be causing the error?


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Range("2:" & Rows.Count).EntireRow.Hidden = False
Range(CStr(3 + 2 * Range("A2").Value) & ":" & _
Rows.Count).EntireRow.Hidden = True
End If
End Sub- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 12:40 PM.

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