How to create controls dynamically at runtime

后端 未结 2 1983
小蘑菇
小蘑菇 2021-01-27 04:41

I am trying to create a variable number of controls (combo boxes) in an excel userform based on the number of columns that are on a particular worksheet being viewed. Ideally I

2条回答
  •  梦如初夏
    2021-01-27 05:00

    With a little bit of math you can get that totally dynamic. Use a frame where you place the controls. Now you have coordinates relative to the frame. Use an "y_offset" and a "lineheight" variable and/or a "x_offset" and a "linewidth" variable and create controls with calculated positions (top and left). During the creation count the offset + (lines*lineheight) and set the Frames ScrollHeight (and/or ScrollWidth) according to the result...

    Did that sometimes. Works very well.

提交回复
热议问题