PC Review


Reply
Thread Tools Rate Thread

centering checkboxes vertical in cell

 
 
ranswert
Guest
Posts: n/a
 
      2nd Jan 2008
I used this code to center a checkbox vertically in a cell and I got a "run
time error object required message". This is the code I entered:

Sub cbox()
Dim cell As Range
Dim chk As Excel.CheckBox
Set cell = ActiveCell
Set chk = wsh.CheckBoxes.Add(cell.Left + 0.3 * cell.Width, cell.Top,
cell.Width, cell.Height)
chk.Height = cell.Height - 1.5

End Sub


 
Reply With Quote
 
 
 
 
Vergel Adriano
Guest
Posts: n/a
 
      2nd Jan 2008
wsh is not defined. Try replacing wsh with ActiveSheet.

--
Hope that helps.

Vergel Adriano


"ranswert" wrote:

> I used this code to center a checkbox vertically in a cell and I got a "run
> time error object required message". This is the code I entered:
>
> Sub cbox()
> Dim cell As Range
> Dim chk As Excel.CheckBox
> Set cell = ActiveCell
> Set chk = wsh.CheckBoxes.Add(cell.Left + 0.3 * cell.Width, cell.Top,
> cell.Width, cell.Height)
> chk.Height = cell.Height - 1.5
>
> End Sub
>
>

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      2nd Jan 2008
I suspect 'wsh' is not set. For example, insert:
Set wsh = ActiveSheet

Hth,
Merjet


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Jan 2008
You didn't declare wsh or tell excel what wsh was.

But since you know the cell that the checkbox goes in, then you can use:

Set chk = cell.parent.CheckBoxes.Add(cell.left + 0.3, ....

The parent of the cell is the worksheet that it's located on.


ranswert wrote:
>
> I used this code to center a checkbox vertically in a cell and I got a "run
> time error object required message". This is the code I entered:
>
> Sub cbox()
> Dim cell As Range
> Dim chk As Excel.CheckBox
> Set cell = ActiveCell
> Set chk = wsh.CheckBoxes.Add(cell.Left + 0.3 * cell.Width, cell.Top,
> cell.Width, cell.Height)
> chk.Height = cell.Height - 1.5
>
> End Sub


--

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
vertical centering charles arnett Microsoft Word Document Management 4 5th Jan 2010 06:05 PM
vertical centering of data voodoo Microsoft Access Forms 4 18th Dec 2009 08:08 PM
centering checkboxes Elan Arad Microsoft Excel Programming 1 11th Mar 2006 05:50 PM
Vertical Centering Ron Microsoft Frontpage 8 8th Apr 2005 06:03 PM
Vertical Centering Vel Microsoft Access Forms 0 14th Aug 2003 01:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:13 PM.