BasicUserWithExp
New Member
- Joined
- Feb 15, 2018
- Messages
- 17
I am a rebar estimator, i have a workbook that contains a quote sheet, and a pricing sheet. i have multiple products, and i want to expand with more. I currently have my quote sheet setup to hide rows using a checkbox, the checkbox also gets hidden. There is a macro that resets the Hidden status of the lines and Check boxes.
I found some code that works for what i want however; i would like to add more lines for more products. it seems the more Check boxes i add the more errors i have.
1. no code errors show
2. multiple Check Boxes appear on top of each other
3. checkbox may hide the wrong line.
4. code may no reset all hidden lines and/or Check Boxes
I found the code online but i cannot find it again to check and see if i made an error somewhere.
I am asking for suggestions on improvements with code and/or setup
I found some code that works for what i want however; i would like to add more lines for more products. it seems the more Check boxes i add the more errors i have.
1. no code errors show
2. multiple Check Boxes appear on top of each other
3. checkbox may hide the wrong line.
4. code may no reset all hidden lines and/or Check Boxes
I found the code online but i cannot find it again to check and see if i made an error somewhere.
Code:
Sub HideRow()
Dim ws As Worksheet
Dim myCBX As CheckBox
Dim lRow As Long
Set ws = ActiveSheet
Set myCBX = ws.CheckBoxes(Application.Caller)
lRow = myCBX.TopLeftCell.Row
Application.ScreenUpdating = False
Select Case myCBX.Value
Case 1 'box is checked
ws.Rows(lRow).EntireRow.Hidden = True
myCBX.Visible = False
Case Else 'box is not checked
ws.Rows(lRow).EntireRow.Hidden = False
myCBX.Visible = True
End Select
Application.ScreenUpdating = True
End Sub
Sub sbHidingUnHideRows()
'To Hide Rows 22 to 25
Rows("11:33").EntireRow.Hidden = True
'To UnHide Rows 22 to 25
Rows("11:33").EntireRow.Hidden = False
End Sub
'Make all rows visible and uncheck all checkboxes
Sub UncheckAll()
Dim ws As Worksheet
Dim myCBX As Excel.CheckBox
Dim lRow As Long
Set ws = ActiveSheet
Application.ScreenUpdating = False
With ws
For Each myCBX In .CheckBoxes
myCBX.Value = xlOff
lRow = myCBX.TopLeftCell.Row
.Rows(lRow).EntireRow.Hidden = False
myCBX.Visible = True
Next myCBX
End With
Application.ScreenUpdating = True
End Sub
I am asking for suggestions on improvements with code and/or setup