PC Review


Reply
Thread Tools Rate Thread

checkbox centered in cell

 
 
ranswert
Guest
Posts: n/a
 
      10th Mar 2008
I have the following code to add a checkbox in a cell and center it top to
bottom:

Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
chk as Excel.checkbox
cell as Range

This code works fine in one procedure, but in another one the checkbox is in
the bottom of the cell.

Any Ideas what to do to fix this?
Thanks
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      10th Mar 2008
Depending on what the size of the cell is, you could play around with something
like:

Dim chk As CheckBox
Dim cell As Range

Set cell = ActiveSheet.Range("E7")

With cell
Set chk = .Parent.CheckBoxes.Add(Left:=.Left, _
Top:=.Top + (.Height / 4), _
Width:=.Width, _
Height:=.Height / 4)
End With



ranswert wrote:
>
> I have the following code to add a checkbox in a cell and center it top to
> bottom:
>
> Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
> chk as Excel.checkbox
> cell as Range
>
> This code works fine in one procedure, but in another one the checkbox is in
> the bottom of the cell.
>
> Any Ideas what to do to fix this?
> Thanks


--

Dave Peterson
 
Reply With Quote
 
ranswert
Guest
Posts: n/a
 
      11th Mar 2008
Thanks
I'll give that a try.

Any idea it works in one procedure, but not another?

"Dave Peterson" wrote:

> Depending on what the size of the cell is, you could play around with something
> like:
>
> Dim chk As CheckBox
> Dim cell As Range
>
> Set cell = ActiveSheet.Range("E7")
>
> With cell
> Set chk = .Parent.CheckBoxes.Add(Left:=.Left, _
> Top:=.Top + (.Height / 4), _
> Width:=.Width, _
> Height:=.Height / 4)
> End With
>
>
>
> ranswert wrote:
> >
> > I have the following code to add a checkbox in a cell and center it top to
> > bottom:
> >
> > Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
> > chk as Excel.checkbox
> > cell as Range
> >
> > This code works fine in one procedure, but in another one the checkbox is in
> > the bottom of the cell.
> >
> > Any Ideas what to do to fix this?
> > Thanks

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Mar 2008
Maybe 12 is too big.



ranswert wrote:
>
> Thanks
> I'll give that a try.
>
> Any idea it works in one procedure, but not another?
>
> "Dave Peterson" wrote:
>
> > Depending on what the size of the cell is, you could play around with something
> > like:
> >
> > Dim chk As CheckBox
> > Dim cell As Range
> >
> > Set cell = ActiveSheet.Range("E7")
> >
> > With cell
> > Set chk = .Parent.CheckBoxes.Add(Left:=.Left, _
> > Top:=.Top + (.Height / 4), _
> > Width:=.Width, _
> > Height:=.Height / 4)
> > End With
> >
> >
> >
> > ranswert wrote:
> > >
> > > I have the following code to add a checkbox in a cell and center it top to
> > > bottom:
> > >
> > > Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
> > > chk as Excel.checkbox
> > > cell as Range
> > >
> > > This code works fine in one procedure, but in another one the checkbox is in
> > > the bottom of the cell.
> > >
> > > Any Ideas what to do to fix this?
> > > Thanks

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
ranswert
Guest
Posts: n/a
 
      11th Mar 2008
Thanks

"Dave Peterson" wrote:

> Maybe 12 is too big.
>
>
>
> ranswert wrote:
> >
> > Thanks
> > I'll give that a try.
> >
> > Any idea it works in one procedure, but not another?
> >
> > "Dave Peterson" wrote:
> >
> > > Depending on what the size of the cell is, you could play around with something
> > > like:
> > >
> > > Dim chk As CheckBox
> > > Dim cell As Range
> > >
> > > Set cell = ActiveSheet.Range("E7")
> > >
> > > With cell
> > > Set chk = .Parent.CheckBoxes.Add(Left:=.Left, _
> > > Top:=.Top + (.Height / 4), _
> > > Width:=.Width, _
> > > Height:=.Height / 4)
> > > End With
> > >
> > >
> > >
> > > ranswert wrote:
> > > >
> > > > I have the following code to add a checkbox in a cell and center it top to
> > > > bottom:
> > > >
> > > > Set chk = cell.Parent.CheckBoxes.Add(cell.Left, cell.Top, 12, cell.Height)
> > > > chk as Excel.checkbox
> > > > cell as Range
> > > >
> > > > This code works fine in one procedure, but in another one the checkbox is in
> > > > the bottom of the cell.
> > > >
> > > > Any Ideas what to do to fix this?
> > > > Thanks
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position shapes to be centered in a cell James Microsoft Excel Programming 2 16th Sep 2009 03:46 PM
Centered Checkbox? JBrown Microsoft Access Reports 3 3rd Jan 2009 07:39 PM
text box is centered when sent but not staying centered when recei =?Utf-8?B?RnJ1c3RyYXRpbmcgVGV4dA==?= Microsoft Outlook Discussion 0 16th Mar 2007 12:47 PM
centered text doesn't print centered =?Utf-8?B?TUhI?= Microsoft Word Document Management 1 3rd Oct 2006 08:36 PM
Cell alignment centered Simon Fischer Microsoft Excel Programming 1 21st Jul 2005 11:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:07 PM.