PDA

View Full Version : Insert forms: Size to user defined range



milken
04-17-2006, 12:18 AM
I'm trying to develop a macro where a user selects a form (like a Check Box or Combo Box) and defines the cell address where that form will be inserted into a worksheet (by using something like refedit).

Getting the form info and the refedit info is relatively easy, but does anyone know how I can tell excel that the form must be placed exactly within the cell range defined in the refedit?

Cheers,
Milken

Jacob Hilderbrand
04-17-2006, 09:30 PM
Here is an example with a RefEdit control on a User Form.


Option Explicit

Private Sub CommandButton1_Click()

Dim Rng As Range

Set Rng = Range(Me.RefEdit1.Value)
Sheet1.OLEObjects.Add "Forms.Checkbox.1", _
Left:=Rng.Left, Top:=Rng.Top, Height:=Rng.Height, Width:=Rng.Width

End Sub


You can then add a Select Case to determine what control to add (based on user input).