Hiding a Scroll Bar in VBA

fordgale

New Member
Joined
Jul 11, 2011
Messages
10
Hi,
I am trying to hide rows which I have named as a range "NumberNights". I have managed to do this successfully except that within these rows is a scroll bar which is not being hidden with the rows. I have tried naming the scroll bar as another range "avgcostnightscrollbar". I gather from previous posts that I have to hide the entire row that the scroll bar is on (which is fine - if it is one of the rows I am trying to hide anyway). My code is as follows (for which I am getting an error on the 6th line):

Private Sub TotalExpend_Click()
If TotalExpend.Value = True Then
Range("OtherHolidayChoice").Value = 1
Range("TotalExpenditure").EntireRow.Hidden = False
Range("NumberNights").EntireRow.Hidden = True
Range("avgcostnightscrollbar").EntireRow.Hidden = True
End If
End Sub

I have tried putting in Sheet name, Object instead of Range etc, but can't get anything to work. Can anyone help me with the correct syntax?
Thanks.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
If you are using a scrollbar from the Forms toolbar then set its Visible Property to False via code.
If however you are using an ActiveX Scrollbar then enter edit mode, right click the scrolllbar, choose Format Control, Properties tab and check the Move and Size with cells option.
 
Upvote 0
Hi Jaafar,
Thank you so much for your response - I really appreciate it.

In your response, do you mean the other way around, i.e. change code for the ActiveX scroll bar not the forms scroll bar? If so, I am using the Forms scroll bar, and the option to move and size with cells is not highlighted on my spreadsheet, therefore not available to me. Is there a way to make it available, or should I change it to an ActiveX scroll bar?

I see what you are saying about changing the "visible" property to false on an ActiveX scroll bar and can see how I would do it manually. However, could I be so cheeky as to ask you if the following coding is anything like correct for automating the change before I go and change the scroll bar type and recode? FYI, "avgcostnightscrollbar" is the range name I have given my scroll bar, otherwise it goes by Scroll Bar 67.

If TotalExpend.Value = True Then
Range("avgcostnightscrollbar").Properties.Visible = False

Thank you so much for your help
Lucinda.
 
Upvote 0
Hi Jaafar,
Thank you so much for your response - I really appreciate it.

In your response, do you mean the other way around, i.e. change code for the ActiveX scroll bar not the forms scroll bar? If so, I am using the Forms scroll bar, and the option to move and size with cells is not highlighted on my spreadsheet, therefore not available to me. Is there a way to make it available, or should I change it to an ActiveX scroll bar?

I see what you are saying about changing the "visible" property to false on an ActiveX scroll bar and can see how I would do it manually. However, could I be so cheeky as to ask you if the following coding is anything like correct for automating the change before I go and change the scroll bar type and recode? FYI, "avgcostnightscrollbar" is the range name I have given my scroll bar, otherwise it goes by Scroll Bar 67.

If TotalExpend.Value = True Then
Range("avgcostnightscrollbar").Properties.Visible = False

Thank you so much for your help
Lucinda.

Maybe something along these lines :

Code:
Private Sub TotalExpend_Click()
    If TotalExpend.Value = True Then
        ActiveSheet.Shapes("Scroll Bar 67").Visible = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top