Why does it offset the Listbox position `? is there a fix

Darkforce

New Member
Joined
Mar 4, 2020
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I try to use this code to get the Listbox to line up with some cell , but for some reason it does not hit the target, and then I need to make an currection (See last linie of the Code. when I add the currection it sames to work and stay the with the topleft corner of the ListeBox in the topleft corner of the Cell even if I make change to they will move together


Set xLstBox = ActiveSheet.AddOptLHF6114

If xLstBox.Visible = False Then
xLstBox.Visible = True
Dim iRowHeight As Long
'Add height row height form and to xxx
For j = 1 To 75
iRowHeight = iRowHeight + Rows(j).Height
Next j
'Change Top Position to Total Rows Height
xLstBox.Top = iRowHeight - 17 'Offset to fix the problem this number change

ListBoxNavnMenu Start after rowMenu Stop at the end of this rowOffset menu
AddOptInletTable
57​
68​
-12​
AddOptInletTableCombi
58​
69​
-12​
AddOptLHF6114
75​
86​
-17​
AddOptKL30Special
28​
39​
-5​
AddOptLKS6114
94​
105​
-20​

hope you can help
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Look at the properties of the listbox control. I think you're wanting Don't move or size with cells?
 
Upvote 0
I want it to be like this ... and stay in the cell like this and I want it to follow the cell without getting broken
 
Upvote 0
1583331774166.png
 
Upvote 0
Ok I think I understand what you're asking. I believe what you want is to keep the listbox locked @ row 76 ?

If so then you want:
xLstBox.Top = Range("1:75").Height + 1

Also, if you want to make sure that checkbox is unchecked so it stays locked @ row 76 / moves with it. Not sure but if you printing form also you could ensure it gets located properly using before_print event.
 
Upvote 0
Also, the placement property should be either 1 or 2, and you should not need to keep changing it's placement.
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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