Positioning Inputbox Below Label and dropdown box

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
So basically I have a few labels and dropdown boxs that once selected it calls a certain macro. My excel sheet is set up such that as you expand the application window column A gets larger to keep everything centered in the excel sheet. So the following code does not work very well since it takes the positioning of the window in the top left corner and adds the textbox therefore if I stretch the window this addtextbox postioning values are no longer in line with my labels and such.

Code:
With Sheets("sheet1")
    .Shapes("Dropdown1).IncrementTop 200
    .Shapes("label1").IncrementTop 200
    .Shapes("dropdown2").IncrementTop 200
    .Shapes("label2").IncrementTop 200
    .Shapes.AddTextbox(msoTextOrientationHorizontal, 314, 215, 700, 150).TextFrame.Characters.Text = "Test Box"
End With

I am wondering if there is a way to get the x and y positioning of my dropdown box and merely input right below that. This allows me to be more consistent with my adding my textboxes right below it.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
I figured out replace the addtextbox values with the position of the object using objectname.left and objectname.top+padding and it does the trick
 
Upvote 0

Forum statistics

Threads
1,195,855
Messages
6,011,973
Members
441,658
Latest member
Carlos O

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
Top