PC Review


Reply
Thread Tools Rate Thread

Checkbox1.LinkedCel = ActiveCell -- "Why wont it work?"

 
 
Time Traveller
Guest
Posts: n/a
 
      11th Sep 2004
Have little bit of code that dumps Activex Checkbox on page, sizes it to fit
in nicely to the ActiveCell. Works beautifully, except I want to make the
linked cel the active cel as well, and I really don't want to have to go
into design mode and do it manually for every checkbox I create. For some
reason this code does not work as I expect. I'm sure theres a fundamental
principle I am unaware of.

Checkbox1.LinkedCel = ActiveCell

Also another question: When dumping the checkboxes on the page, they are
incremented by 1..eg Checkbox1, Checkbox2 etc. Seems to me there must be an
index somewhere that keeps track of these. How can I refer these checkboxes
by their ordinal number programmatically at runtime so that I can do
operations with the checkbox at that time, using the index or the ordinal
part of the string. I could write something to strip the ordinal part out of
the name, but that seems like a major kluge.


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Sep 2004
This worked ok for me:

Worksheets("sheet1").CheckBox1.LinkedCell = ActiveCell.Address(external:=True)

From a previous post that may help you:


If I knew how many checkboxes there were and they were named nicely, I'd do
something like:

Option Explicit
Sub testme()
Dim iCtr As Long
For iCtr = 1 To 4
Sheet1.OLEObjects("checkbox" & iCtr).Object.Value = False
Next iCtr
End Sub

If I wanted to get them all, but didn't know how many, I could get them this
way:

Sub testme2()

Dim OLEobj As OLEObject

For Each OLEobj In Sheet1.OLEObjects
If TypeOf OLEobj.Object Is MSForms.CheckBox Then
OLEobj.Object.Value = False
End If
Next OLEobj

End Sub

If you knew the names of just the checkboxes you wanted to change:

Sub testme3()
Dim iCtr As Long
Dim myCBXNames As Variant
myCBXNames = Array("checkbox1", "checkbox2")
For iCtr = LBound(myCBXNames) To UBound(myCBXNames)
Sheet1.OLEObjects(myCBXNames(iCtr)).Object.Value = False
Next iCtr
End Sub

Time Traveller wrote:
>
> Have little bit of code that dumps Activex Checkbox on page, sizes it to fit
> in nicely to the ActiveCell. Works beautifully, except I want to make the
> linked cel the active cel as well, and I really don't want to have to go
> into design mode and do it manually for every checkbox I create. For some
> reason this code does not work as I expect. I'm sure theres a fundamental
> principle I am unaware of.
>
> Checkbox1.LinkedCel = ActiveCell
>
> Also another question: When dumping the checkboxes on the page, they are
> incremented by 1..eg Checkbox1, Checkbox2 etc. Seems to me there must be an
> index somewhere that keeps track of these. How can I refer these checkboxes
> by their ordinal number programmatically at runtime so that I can do
> operations with the checkbox at that time, using the index or the ordinal
> part of the string. I could write something to strip the ordinal part out of
> the name, but that seems like a major kluge.


--

Dave Peterson
(E-Mail Removed)
 
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
Zeon, DocuCom, DocuComPDF - Word 2003's "cut and paste" wont work? Mike Lynch Microsoft Word Document Management 1 30th Oct 2009 09:37 PM
Replace(ActiveCell.Formula, "Round(","") not working as expected Dennis Microsoft Excel Programming 3 16th May 2007 04:49 PM
ReVIEW (Erratum): some shortcut keys not working anymore-----help""""""""PhpApach...WORK WELL!!!! wbrowse@gmail.com Windows XP Help 0 13th Apr 2007 12:29 PM
"Deny" Explorer and windows wont work. =?Utf-8?B?U2NvdHQgQnVya2U=?= Windows XP Security 1 30th Jan 2006 10:03 PM
Checkbox1.LinkedCell = ActiveCell "Why wont this work?& TimeTraveller - ExcelForums.com Microsoft Excel Programming 2 11th Sep 2004 09:05 PM


Features
 

Advertising
 

Newsgroups
 


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