Need help with IF statement/macro

Xlixen1

New member
Local time
Today, 12:00
Joined
Oct 28, 2007
Messages
4
I have attached the appropriate spreadsheet for what I want doing.

Basically,
I would like 8 checkboxes displaying 'Processor' (Already there) Motherboard, Memory etc.

When these checkboxes are unchecked, I would like the row that the checkbox corresponds to (For example, 'Processor' is row 15) to be hidden. When that box is checked, I would like that row to be unhidden. I wondered if this is possible to do with an IF statement from the 'True' or 'False' readings that the checkboxes give.
Otherwise, Is it possible to code macros to do this?

Thanks for any help anyone can give. I am most grateful :)

(Now Attached)
 

Attachments

Last edited:
Okay thanks, have done.
Is there anyone who can help me?
Thanks.
 
The problem with your description is that once the row is hidden, there is no way for the person to check it in a hidden row. Unless you want a button to reset everything. But what would you reset it to? If to none, then the code will hide the row, so back to original problem.
________
Honda Dylan 125 Specifications
 
Last edited:
I wanted the rows to be hidden by checking a checkbox. I intended for the checkboxes to be located above the rows that were being hidden.
I know it's difficult to explain what I would like. But basically, I want checkboxes above the selections, and when the checkboxes are checked, the selections are visible, and when unchecked they will be hidden.

If it would be easier I could do a screenshot and manipulate the image to show you what I would like =/
Thanks a lot.
 
Okay, now I understand. Thanks

Let me play with it a little. It is do-able. But I also have three projects to work on today. :)
________
Sex Advice Dicussion
 
Last edited:
You mean like the attached?

Just add that VB code but for other check boxes if so.

Code:
Sub Processor_Unhide()

    Rows("15").Select
    If Selection.EntireRow.Hidden Then
        Selection.EntireRow.Hidden = False
    Else
        Selection.EntireRow.Hidden = True
    End If
    
End Sub

Is this what you meant?
 

Attachments

Probably a better solution though is to use the VB control box (through toolbars / Visual Basic) and use the code below:

Code:
Private Sub Processor_Click()
On Error GoTo Processor_Err

    Dim rn As String
    
    Application.ScreenUpdating = False
    
    ' Store currently selected cell
    rn = ActiveCell.AddressLocal

    Rows("15").Select
    If Processor.Value = True Then
        ' unhide the row
        Selection.EntireRow.Hidden = False
    Else
        ' hide the row
        Selection.EntireRow.Hidden = True
    End If
    
    ' return to cell selected prior to running macro
    Range(rn).Select

Processor_Err:
    Application.ScreenUpdating = True

End Sub

This works in a similar way but is more robust as whenever the check box is true it will show the row (whereas before the user could hide it and then it would mess up the checkbox value tallying with the row visibility).

Also, I've added a bit more code to return to the cell that was selected before you clicked the checkbox, and also to turn off the screen updating whilst it's hiding the row.

Hope this helps
 

Users who are viewing this thread

Back
Top Bottom