+ Reply to Thread
Results 1 to 4 of 4

Naming command buttons on a UserForm

  1. #1
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245

    Naming command buttons on a UserForm

    Hi,
    I have a UserForm named UFListSelector. On it are 8 command buttons that I want the names to be the value of the range of cells A1:H1 on sheet RoomItems. I'm getting a run-time error 13
    type mismatched error.

    Here is the Code:

    Option Explicit
    Private Sub cmdShowItemSelect_Click()
    Dim i As Integer

    UFListSelector.RefEdit1.Value = ActiveCell.Address
    For i = 1 To 8
    UFListSelector.Controls("CommandButton" & i).Caption = _
    ActiveWorkbook.Sheets("RoomItems").Range(Columns(i) & "1").Value
    Next i

    UFListSelector.Show
    End Sub
    Casey

  2. #2
    Roger Whitehead
    Guest

    Re: Naming command buttons on a UserForm

    > ActiveWorkbook.Sheets("RoomItems").Range(Columns(i) & "1").Value
    Shouldn't this be
    ActiveWorkbook.Sheets("RoomItems").cells(1,i).Value
    ?


    --
    HTH
    Roger
    Shaftesbury (UK)


    "Casey" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    > I have a UserForm named UFListSelector. On it are 8 command buttons
    > that I want the names to be the value of the range of cells A1:H1 on
    > sheet RoomItems. I'm getting a run-time error 13
    > type mismatched error.
    >
    > Here is the Code:
    >
    > Option Explicit
    > Private Sub cmdShowItemSelect_Click()
    > Dim i As Integer
    >
    > UFListSelector.RefEdit1.Value = ActiveCell.Address
    > For i = 1 To 8
    > UFListSelector.Controls("CommandButton" & i).Caption = _
    > ActiveWorkbook.Sheets("RoomItems").Range(Columns(i) & "1").Value
    > Next i
    >
    > UFListSelector.Show
    > End Sub
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile:
    > http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=530958
    >




  3. #3
    Bob Phillips
    Guest

    Re: Naming command buttons on a UserForm

    Try

    UFListSelector.Controls("CommandButton" & i).Caption = _
    ActiveWorkbook.Sheets("RoomItems").Cells(1, i).Value


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Casey" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi,
    > I have a UserForm named UFListSelector. On it are 8 command buttons
    > that I want the names to be the value of the range of cells A1:H1 on
    > sheet RoomItems. I'm getting a run-time error 13
    > type mismatched error.
    >
    > Here is the Code:
    >
    > Option Explicit
    > Private Sub cmdShowItemSelect_Click()
    > Dim i As Integer
    >
    > UFListSelector.RefEdit1.Value = ActiveCell.Address
    > For i = 1 To 8
    > UFListSelector.Controls("CommandButton" & i).Caption = _
    > ActiveWorkbook.Sheets("RoomItems").Range(Columns(i) & "1").Value
    > Next i
    >
    > UFListSelector.Show
    > End Sub
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile:

    http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=530958
    >




  4. #4
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245
    Roger & Bob,
    "Doh!"
    Thank you very much. Works now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1