View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default location of combobox and chart

Marvelous solution Leith,

I just tested using your your idea to modify recorded code of creating a
combo box and it works perfectly.

Recorded code to create combo box:-

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1", Link:=False, _
DisplayAsIcon:=False, Left:=96, Top:=24.75, Width:=144.75,
Height:=27 _
).Select

Modified to position combo box based on cell position:-

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1", Link:=False, _
DisplayAsIcon:=False, Left:=Range("D10").Left,
Top:=Range("D10").Top, Width:=144.75, Height:=27 _
).Select

Hope it works well for you Sammy.

Regards,

OssieMac



"Leith Ross" wrote:

On Aug 19, 3:25 pm, wrote:
i was wondering if its possible to select a cell on a sheet where to
put a combobox or a chart rather than by pixel.
i am planning on making one sheet called graphs which will have 25
graphs each with their own combobox. when you select an item from the
combo box list it is going to graph that column from another worksheet
on that page but I dont know how to spread them out automatically.

I wanted to use a macro to make it for me.

thanks
sammy


Hello Sammy,

You can reposition an object by setting its Left and Top properties to
same as the selected cell. This macro will move the chart named "Chart
1" on the Active sheet so the upper left corner of the chart is in the
upper left corner of cell D10. This same method will work for the
ComboBox as well.

Sub MoveChart()

With ActiveSheet
.ChartObjects("Chart 1").Left = .Range("D10").Left
.ChartObjects("Chart 1").Top = .Range("D10").Top
End With

End Sub

Sincerely,
Leith Ross