centering checkboxes in non-adjacent ranges

pullmyefinger

Board Regular
Joined
Mar 9, 2011
Messages
69
this code was originally given by QuietRiot or someone, I don't remember.

I can't get my additions to work and don't understand how to setup or navigate all the cells in a range(s).

Can someone explain what is missing?? The example given in the forum does not work so something must be missing or I don't understand how to apply it to my sheet or any range(s).

My example ranges are G4:G6,K10:K11 in my practice sheet.




Sub CenterBox()

Dim rng As Range
Dim Box As Object

Worksheets("P").Activate

Set rng = Worksheets("P").Range("G4:G6,K10:K11")


For Each Box In ActiveSheet.CheckBoxes
Set rng = Box.TopLeftCell
Box.Left = rng.Left + (rng.Width - Box.Width) / 2
Box.Top = rng.Top + (rng.Height - Box.Height) / 2
Next
End Sub
 
Please clarify the following...

  1. How many target ranges do you have?
  2. Where are your ranges located?
  3. How many CheckBoxes do you have?
  4. What are their names?
  5. Where are they located?
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
3 target ranges (checkboxes)

I. D9 : D22 ( 14 named as check box 561 - check box 574 )

II. I8 : I22 ( 15 named as 575 - 589 )

III. M8 : M22 ( 15 named as 590 - 604 )
---
44 checkboxes in a worksheet tab called "this month"

Each checkbox is linked to the cell it is above. I know they are not actually "stored" in the cells.


IV. I deleted all the aforementioned checkboxes and redid them as checkboxes 561 to 604 just to rule that possibility out. No luck. 4 or 5 Checkboxes are being stacked one on top of the other to make them "look like" they were deleted. Two boxes were put in 1 cell side by side.

V. Moved the checkboxes and make all their boundaries as small as possible, along with deleting the text names in every single one.

Thanks for helping, Domenic. This is getting to be a pain, but we have gone to far to quit now (if I am "reading" you correctly).

Joe
 
Upvote 0
If there were a number of CheckBoxes stacked one on top of another it would suggest that a cell can contain more than one CheckBox. Is this the case?
 
Upvote 0
2 in one box? has to be because it happened, but the cboxes were still linked to the correct cells. can i send you the worksheet from here?
 
Upvote 0
in cell I8 were the checkboxes for I8 and I9. they looked like they were centered as one "unit".

i was going to send the scaled down version of the sheet but it won't let me attach anything.
 
Upvote 0
Let me try to re-phrase my question. You said that after you ran my macro, there were a number of CheckBoxes stacked one on top of another. For that to happen, it means that there must have been more than CheckBox within a cell to start with. Was that the case? If I understood you correctly from the start, each cell contains a CheckBox, and you simply want to center each one within the cell they're in, is this correct?

By the way, there's no way to attached a sample workbook on this Board. You can, however, provide a link to an image you place elsewhere, such as ImageShack, etc.
 
Upvote 0
ok, one checkbox per cell at the start. they just need to be centered in the cells. there were not 2 checkboxes in any cell to start with.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,700
Members
452,938
Latest member
babeneker

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