![]() |
VBA dynamically change width listbox
It's really ListBox2. ListBox1 is part of another Userform.
-- met vriendelijke groetjes "JLGWhiz" schreef in bericht ... Would it be presumptious to think that since you have only one listbox on the form that maybe it should be ListBox1 in the code instead of ListBox2? "Frederik" wrote: Using Windows XP Eccel 2003 On a UserForm there are only one ListBox and one OK button. I would like to change the width of the UserForm, the width of the ListBox and the position of the OK button, depending on the largest element in the ListBox (depending on the variable atl). I'm using this code: UserForm2.Width = atl * 158 / 31 + 80 UserForm2.ListBox2.Width = atl * 158 / 31 + 5 UserForm2.OKknop.Left = atl * 158 / 31 + 25 When I use Show to activate UserForm2 , the width of the UserForm and the position of the OK button are changed, but not the width of the ListBox! Why not? Any hint is very welcome! -- met vriendelijke groetjes |
VBA dynamically change width listbox
Supplementary information:
If I put a Msgbox instruction in the code to display whatever message, then the width of the listbox ís changed! Strange ... But I don't want that message on screen... -- met vriendelijke groetjes "Frederik" schreef in bericht ... Using Windows XP Eccel 2003 On a UserForm there are only one ListBox and one OK button. I would like to change the width of the UserForm, the width of the ListBox and the position of the OK button, depending on the largest element in the ListBox (depending on the variable atl). I'm using this code: UserForm2.Width = atl * 158 / 31 + 80 UserForm2.ListBox2.Width = atl * 158 / 31 + 5 UserForm2.OKknop.Left = atl * 158 / 31 + 25 When I use Show to activate UserForm2 , the width of the UserForm and the position of the OK button are changed, but not the width of the ListBox! Why not? Any hint is very welcome! -- met vriendelijke groetjes |
VBA dynamically change width listbox
Problem solved!
I moved the procedure to change the width of the listbox to the procedure accompagning userform2 public sub userform_activate() userform2.listbox2.width = atl*158/31+5 end sub and defined the variable atl as a public variable in my first module -- met vriendelijke groetjes "Frederik" schreef in bericht ... Supplementary information: If I put a Msgbox instruction in the code to display whatever message, then the width of the listbox ís changed! Strange ... But I don't want that message on screen... -- met vriendelijke groetjes "Frederik" schreef in bericht ... Using Windows XP Eccel 2003 On a UserForm there are only one ListBox and one OK button. I would like to change the width of the UserForm, the width of the ListBox and the position of the OK button, depending on the largest element in the ListBox (depending on the variable atl). I'm using this code: UserForm2.Width = atl * 158 / 31 + 80 UserForm2.ListBox2.Width = atl * 158 / 31 + 5 UserForm2.OKknop.Left = atl * 158 / 31 + 25 When I use Show to activate UserForm2 , the width of the UserForm and the position of the OK button are changed, but not the width of the ListBox! Why not? Any hint is very welcome! -- met vriendelijke groetjes |
VBA dynamically change width listbox
Glad you found a solution. I had assumed that the code was in the initialize
event. I should have followed my own rule and never assume anything. "Frederik" wrote: Problem solved! I moved the procedure to change the width of the listbox to the procedure accompagning userform2 public sub userform_activate() userform2.listbox2.width = atl*158/31+5 end sub and defined the variable atl as a public variable in my first module -- met vriendelijke groetjes "Frederik" schreef in bericht ... Supplementary information: If I put a Msgbox instruction in the code to display whatever message, then the width of the listbox Ã*s changed! Strange ... But I don't want that message on screen... -- met vriendelijke groetjes "Frederik" schreef in bericht ... Using Windows XP Eccel 2003 On a UserForm there are only one ListBox and one OK button. I would like to change the width of the UserForm, the width of the ListBox and the position of the OK button, depending on the largest element in the ListBox (depending on the variable atl). I'm using this code: UserForm2.Width = atl * 158 / 31 + 80 UserForm2.ListBox2.Width = atl * 158 / 31 + 5 UserForm2.OKknop.Left = atl * 158 / 31 + 25 When I use Show to activate UserForm2 , the width of the UserForm and the position of the OK button are changed, but not the width of the ListBox! Why not? Any hint is very welcome! -- met vriendelijke groetjes |
VBA dynamically change width listbox
Thanks for your thinking with me anyway!
-- met vriendelijke groetjes "JLGWhiz" schreef in bericht ... Glad you found a solution. I had assumed that the code was in the initialize event. I should have followed my own rule and never assume anything. "Frederik" wrote: Problem solved! I moved the procedure to change the width of the listbox to the procedure accompagning userform2 public sub userform_activate() userform2.listbox2.width = atl*158/31+5 end sub and defined the variable atl as a public variable in my first module -- met vriendelijke groetjes "Frederik" schreef in bericht ... Supplementary information: If I put a Msgbox instruction in the code to display whatever message, then the width of the listbox ís changed! Strange ... But I don't want that message on screen... -- met vriendelijke groetjes "Frederik" schreef in bericht ... Using Windows XP Eccel 2003 On a UserForm there are only one ListBox and one OK button. I would like to change the width of the UserForm, the width of the ListBox and the position of the OK button, depending on the largest element in the ListBox (depending on the variable atl). I'm using this code: UserForm2.Width = atl * 158 / 31 + 80 UserForm2.ListBox2.Width = atl * 158 / 31 + 5 UserForm2.OKknop.Left = atl * 158 / 31 + 25 When I use Show to activate UserForm2 , the width of the UserForm and the position of the OK button are changed, but not the width of the ListBox! Why not? Any hint is very welcome! -- met vriendelijke groetjes |
All times are GMT +1. The time now is 05:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com