Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default format checkbox

I want to center checkboxes I have added in the middle of a cell. Can I do
that? Here is my code...

Option Explicit
Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range
Dim RAN As Range

Set RAN = ActiveCell
With ActiveSheet
.CheckBoxes.Delete
For Each myCell In RAN

With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Offset(0, 7).Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
'.OnAction = "'" & ThisWorkbook.Name & "'!dothework"
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default format checkbox

This seemed to work ok for me:

Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, _
Width:=24, _
Left:=.Left + ((.Width - 24) / 2), _
Height:=.Height)

You could fiddle with that width if it's off a bit.

John wrote:

I want to center checkboxes I have added in the middle of a cell. Can I do
that? Here is my code...

Option Explicit
Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range
Dim RAN As Range

Set RAN = ActiveCell
With ActiveSheet
.CheckBoxes.Delete
For Each myCell In RAN

With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Offset(0, 7).Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
'.OnAction = "'" & ThisWorkbook.Name & "'!dothework"
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default format checkbox

Thanks again Dave, your a champ!

"Dave Peterson" wrote:

This seemed to work ok for me:

Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, _
Width:=24, _
Left:=.Left + ((.Width - 24) / 2), _
Height:=.Height)

You could fiddle with that width if it's off a bit.

John wrote:

I want to center checkboxes I have added in the middle of a cell. Can I do
that? Here is my code...

Option Explicit
Sub addCBX()
Dim myCBX As CheckBox
Dim myCell As Range
Dim RAN As Range

Set RAN = ActiveCell
With ActiveSheet
.CheckBoxes.Delete
For Each myCell In RAN

With myCell
Set myCBX = .Parent.CheckBoxes.Add _
(Top:=.Top, Width:=.Width, _
Left:=.Left, Height:=.Height)
With myCBX
.LinkedCell = myCell.Offset(0, 7).Address(external:=True)
.Caption = ""
.Name = "CBX_" & myCell.Address(0, 0)
'.OnAction = "'" & ThisWorkbook.Name & "'!dothework"
End With
.NumberFormat = ";;;"
End With

Next myCell
End With
End Sub


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
In Excel how does one the format/size of a checkbox AmandasConfused Excel Discussion (Misc queries) 3 April 26th 10 03:23 PM
Format Checkbox text AndyC812 Excel Discussion (Misc queries) 0 November 23rd 08 09:54 PM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
format an entire column to contain checkbox activex control blunoob New Users to Excel 1 December 19th 05 02:07 PM
checkbox on form reset from checkbox on sheet raw[_12_] Excel Programming 1 December 3rd 05 05:08 AM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"