Consulting

Results 1 to 2 of 2

Thread: Insert forms: Size to user defined range

  1. #1
    VBAX Newbie
    Joined
    Feb 2006
    Posts
    4
    Location

    Insert forms: Size to user defined range

    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

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Here is an example with a RefEdit control on a User Form.

    [vba]
    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
    [/vba]

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •