Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default setting LinkedCell using VBA

Hi All,

Can anybody tell me why this doesn't work? Excel 2003

Sub testcbx()
Dim cb As Shape
Dim RowNo As Integer
On Error Resume Next
RowNo = 12
For Each cb In ActiveSheet.Shapes
If cb.Name Like "ComboBox*" Then
cb.LinkedCell = "Petty Cash Expenses!H" & RowNo
End If
RowNo = RowNo + 1
Next

TIA

Regards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default setting LinkedCell using VBA

Because a shape doesn't have a linkedcell property.

Assume it is a combobox from the control toolbox toolbar

Dim ole as OleObject
Dim RowNo as Long
RowNo = 12
for each ole in activesheet.OleObjects
if typeof ole.Object is MSForms.Combobox then
ole.LinkedCell = "Petty Cash Expenses!H" & RowNo
RowNo = RowNo + 1
end if
Next

--
Regards,
Tom Ogilvy


"michael.beckinsale" wrote in message
ups.com...
Hi All,

Can anybody tell me why this doesn't work? Excel 2003

Sub testcbx()
Dim cb As Shape
Dim RowNo As Integer
On Error Resume Next
RowNo = 12
For Each cb In ActiveSheet.Shapes
If cb.Name Like "ComboBox*" Then
cb.LinkedCell = "Petty Cash Expenses!H" & RowNo
End If
RowNo = RowNo + 1
Next

TIA

Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default setting LinkedCell using VBA


Tom,

Many thanks, your a diamond. Amended code slightly because l have other
ComboBoxes l dont want to include. There are approx 100 of these so you
can see why l didn't want to set each of them by hand.

Dim ole As OLEObject
Dim RowNo As Long
RowNo = 11
For Each ole In ActiveSheet.OLEObjects
If TypeOf ole.Object Is MSForms.ComboBox Then
If ole.Name Like "ComboBox*" Then
ole.LinkedCell = "H" & RowNo
RowNo = RowNo + 1
End If
End If
Next

Regards

Michael Beckinsale

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
Export Linkedcell racerman Excel Programming 2 September 5th 05 08:39 PM
Setting LinkedCell on a CheckBox Control scottrell Excel Programming 2 July 30th 04 11:06 PM
Setting LinkedCell of individual OptionButton Angelito Cruz Excel Programming 3 June 1st 04 09:25 PM
LinkedCell Update does not always respond Jeroen Kluytmans Excel Programming 4 April 16th 04 08:58 AM
Linkedcell Problems... cornishbloke[_25_] Excel Programming 3 January 21st 04 02:45 PM


All times are GMT +1. The time now is 09:39 PM.

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

About Us

"It's about Microsoft Excel"