Naming command buttons on a UserForm

C

Casey

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
 
R

Roger Whitehead

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

Bob Phillips

Try

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


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top