kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I am challenged with this code and I need help to fix it.
I want to dynamically grow the height of my userform based on the visibility status of some controls as seen from my script below.
The only issue is that I have spent hours trying to figure out the right way to do it but none has given me something cooler.
The controls: exp3, exp5, exp7 and so on are those switching the visibility of exp4, exp6, exp8 and so on.
So I am calling this macro inside the change event of exp3, exp5, exp7 and so on. When exp3, exp5, exp7 and so on contain data, I make visible, exp4, exp6, exp8 and so on else I hide them.
I was thinking that I should be able to control the height of my form as well but it turned out my knowledge level is a bit limited in doing such trick at the moment.
I need someone to pull me out. Thanks in advance.
I want to dynamically grow the height of my userform based on the visibility status of some controls as seen from my script below.
The only issue is that I have spent hours trying to figure out the right way to do it but none has given me something cooler.
The controls: exp3, exp5, exp7 and so on are those switching the visibility of exp4, exp6, exp8 and so on.
So I am calling this macro inside the change event of exp3, exp5, exp7 and so on. When exp3, exp5, exp7 and so on contain data, I make visible, exp4, exp6, exp8 and so on else I hide them.
I was thinking that I should be able to control the height of my form as well but it turned out my knowledge level is a bit limited in doing such trick at the moment.
I need someone to pull me out. Thanks in advance.
Code:
Sub checkActiveBox()
Dim n&, s#, TbRay, j&
TbRay = Array( _
164.25, 189.75, 213.75, 237.75, 261, _
285.75, 309, 333, 357.75, 380.25, 404.25, 429, 453.75, 477 _
)
'j = 0
For i = 4 To 30 Step 2
If Controls("exp" & i).Visible = True Then
j = i - 4
Else
j = 0
End If
Next i
Me.Height = TbRay(j)
End Sub