Consulting

Results 1 to 6 of 6

Thread: CANNOT PLACE BUTTON IN SPECIFIED LOCATION

  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location

    CANNOT PLACE BUTTON IN SPECIFIED LOCATION

    I am running a macro that places an option button in my worksheet. However, I cannot place it in the location I want. When running the macro the button is placed wherever the cursor is.

    I tried the running the macro using:

    Sub ShowPerBox()
        Dim rng As Range
        Set rng = ActiveSheet.Range("L18")
        With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
            .Name = "OptionButton1"
            .Caption = "CONFIRM"
        End With
      
    End Sub
    Am I missing something?

  2. #2
    Try
    Sub ShowPerBox()
        Dim rng As Range
        Set rng = ActiveSheet.Range("L18")
        With ActiveSheet.OptionButtons.Add(rng.Left, rng.Top, rng.Width, rng.Height)
            .Name = "OptionButton1"
            .Caption = "CONFIRM"
        End With
      
    End Sub

  3. #3
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    5
    Location
    Hi there

    With ActiveSheet.OptionButtons.Add(Selection.Left, Selection.Top, Selection.Width, Selection.Height)
    Selection here means that button will place in the area which is selected, if you select amount of cells it will cover them. Or if not, it will be placed in the area of the cursor.

    To make it way you want replace it with for example (30,30,30,30) , it will place button in the area of 3 cells with width and height of 2 cells. (default cells 15x15)

    Best of luck!

  4. #4
    VBAX Regular
    Joined
    Nov 2018
    Location
    London, U.K.
    Posts
    99
    Location
    Thank you both!!

    How can I change the font of the button to:

    Source Sans Pro - Size 14 - Bold

  5. #5
    Not sure that you can

  6. #6
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    5
    Location
    For just button there is not that property, but you can use ActiveX command button and useCommandButton1.BackColor = 12713921.

Posting Permissions

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