Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do I copy a combobox to many cells with relative reference?

I have made a combobox form control and want to copy it to multiple cells,
the problem being the cell link reference is absolute by default and not
relative. Is there a quick way to copy comboboxes and make them relative
references instead of absolute?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I copy a combobox to many cells with relative reference?

I don't think so. Have you thought of using data|validation instead?

If you can't use Data|Validation...

When I want multiple dropdowns from the Forms toolbar, I'll use a macro.

If you want to try:

Option Explicit
Sub testme1()
Dim myDropDown As DropDown
Dim myRng As Range
Dim myCell As Range
Dim myList As Range

With Worksheets("Sheet2")
Set myList = .Range("a1:A10")
End With

With Worksheets("sheet1")
.DropDowns.Delete 'nice for testing???

Set myRng = .Range("a1:a4,c9")

For Each myCell In myRng.Cells
With myCell
.NumberFormat = ";;;" 'hide the value in the cell
Set myDropDown = .Parent.DropDowns.Add _
(Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
End With

With myDropDown
.LinkedCell = myCell.Address(external:=True)
.ListFillRange = myList.Address(external:=True)
End With
Next myCell
End With

End Sub

If you used the combobox from the control toolbox toolbar:

Option Explicit
Sub testme()
Dim OLEObj As OLEObject
Dim myRng As Range
Dim myCell As Range
Dim myList As Range

With Worksheets("Sheet2")
Set myList = .Range("a1:A10")
End With

With Worksheets("sheet1")
For Each OLEObj In .OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
OLEObj.Delete
End If
Next OLEObj

Set myRng = .Range("a1:a4,c9")
For Each myCell In myRng.Cells
With myCell
.NumberFormat = ";;;" 'hide the value in the cell
Set OLEObj = .Parent.OLEObjects.Add _
(ClassType:="Forms.ComboBox.1", Link:=False, _
DisplayAsIcon:=False, _
Top:=.Top, _
Left:=.Left, _
Width:=.Width, _
Height:=.Height)
End With

With OLEObj
.LinkedCell = myCell.Address(external:=True)
.ListFillRange = myList.Address(external:=True)
End With
Next myCell
End With

End Sub


Levc wrote:

I have made a combobox form control and want to copy it to multiple cells,
the problem being the cell link reference is absolute by default and not
relative. Is there a quick way to copy comboboxes and make them relative
references instead of absolute?


--

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
Changing Cells from Relative to Absolute Reference PZ Excel Discussion (Misc queries) 16 April 11th 07 08:22 PM
Copy data from pivot table using relative reference hello Excel Discussion (Misc queries) 5 April 9th 07 04:13 PM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
Copy a relative reference formula from one sheet to another. jannkatt Excel Discussion (Misc queries) 3 May 17th 06 07:13 PM
changing multiple cells from relative to absolute reference Mike Excel Discussion (Misc queries) 4 March 10th 05 02:11 PM


All times are GMT +1. The time now is 09:59 AM.

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"