switters_aka
Board Regular
- Joined
- Oct 26, 2010
- Messages
- 118
would really like some help with this if anyone has the time. I am calling userform1 with a command button on a worksheet. The form was doing exactly what I wanted it to do yesterday although I am not confident how I got there. Today however, someone else tried to run the workbook on another PC and got the object or block variable not set error. I am now getting the same error and I have no idea how to fix this. Probably something basic but as a newbie to VBA I can't see it. Any help would be greatly appreciated. Thanks in advance.
'command button code ---->
Private Sub cmdLB1_Click()
Dim userform1 As Object
userform1.Show vbModeless
End Sub
'userform code----->
Private Sub UserForm_Initialize()
'Macro Purpose: To populate a multi-column listbox with data from
' a worksheet range
Dim lbtarget As ListBox
Dim rngSource As Range
Dim subrng As Range
Dim rownum As Integer
'Set subrng = Worksheets("Criterias).Range("qual_val")
rownum = ActiveCell.Row
If rownum = 3 Then
Worksheets("Criterias").Range("selfrel_val").Name = "MyRange"
ElseIf rownum = 4 Then
Worksheets("Criterias").Range("excon_val").Name = "MyRange"
ElseIf rownum = 5 Then
Worksheets("Criterias").Range("Qual_val").Name = "MyRange"
ElseIf rownum = 6 Then
Worksheets("Criterias").Range("coord_val").Name = "MyRange"
ElseIf rownum = 7 Then
Worksheets("Criterias").Range("stratskills_val").Name = "MyRange"
ElseIf rownum = 8 Then
Worksheets("Criterias").Range("conskills_val").Name = "MyRange"
ElseIf rownum = 9 Then
Worksheets("Criterias").Range("techskills_val").Name = "MyRange"
ElseIf rownum = 10 Then
Worksheets("Criterias").Range("lmr_val").Name = "MyRange"
ElseIf rownum = 11 Then
Worksheets("Criterias").Range("rfrep_val").Name = "MyRange"
ElseIf rownum = 12 Then
Worksheets("Criterias").Range("pi_prog_val").Name = "MyRange"
ElseIf rownum = 13 Then
Worksheets("Criterias").Range("pi_org_val").Name = "MyRange"
ElseIf rownum = 14 Then
Worksheets("Criterias").Range("pi_shs_val").Name = "MyRange"
ElseIf rownum = 15 Then
Worksheets("Criterias").Range("wk_con_val").Name = "MyRange"
ElseIf rownum = 16 Then
Worksheets("Criterias").Range("wk_hrs_val").Name = "MyRange"
ElseIf rownum = 17 Then
Worksheets("Criterias").Range("phys_bur_val").Name = "MyRange"
End If
'MsgBox rownum
'Set reference to the range of data to be filled
Set rngSource = Worksheets("Criterias").Range("MyRange")
'Fill the listbox
Set lbtarget = Me.ListBox1
With lbtarget
'Determine number of columns
.ColumnCount = 2
'Set column widths
.ColumnWidths = "50;100"
'Insert the range of data supplied
.List = rngSource.Cells.Value
End With
End Sub
'command button code ---->
Private Sub cmdLB1_Click()
Dim userform1 As Object
userform1.Show vbModeless
End Sub
'userform code----->
Private Sub UserForm_Initialize()
'Macro Purpose: To populate a multi-column listbox with data from
' a worksheet range
Dim lbtarget As ListBox
Dim rngSource As Range
Dim subrng As Range
Dim rownum As Integer
'Set subrng = Worksheets("Criterias).Range("qual_val")
rownum = ActiveCell.Row
If rownum = 3 Then
Worksheets("Criterias").Range("selfrel_val").Name = "MyRange"
ElseIf rownum = 4 Then
Worksheets("Criterias").Range("excon_val").Name = "MyRange"
ElseIf rownum = 5 Then
Worksheets("Criterias").Range("Qual_val").Name = "MyRange"
ElseIf rownum = 6 Then
Worksheets("Criterias").Range("coord_val").Name = "MyRange"
ElseIf rownum = 7 Then
Worksheets("Criterias").Range("stratskills_val").Name = "MyRange"
ElseIf rownum = 8 Then
Worksheets("Criterias").Range("conskills_val").Name = "MyRange"
ElseIf rownum = 9 Then
Worksheets("Criterias").Range("techskills_val").Name = "MyRange"
ElseIf rownum = 10 Then
Worksheets("Criterias").Range("lmr_val").Name = "MyRange"
ElseIf rownum = 11 Then
Worksheets("Criterias").Range("rfrep_val").Name = "MyRange"
ElseIf rownum = 12 Then
Worksheets("Criterias").Range("pi_prog_val").Name = "MyRange"
ElseIf rownum = 13 Then
Worksheets("Criterias").Range("pi_org_val").Name = "MyRange"
ElseIf rownum = 14 Then
Worksheets("Criterias").Range("pi_shs_val").Name = "MyRange"
ElseIf rownum = 15 Then
Worksheets("Criterias").Range("wk_con_val").Name = "MyRange"
ElseIf rownum = 16 Then
Worksheets("Criterias").Range("wk_hrs_val").Name = "MyRange"
ElseIf rownum = 17 Then
Worksheets("Criterias").Range("phys_bur_val").Name = "MyRange"
End If
'MsgBox rownum
'Set reference to the range of data to be filled
Set rngSource = Worksheets("Criterias").Range("MyRange")
'Fill the listbox
Set lbtarget = Me.ListBox1
With lbtarget
'Determine number of columns
.ColumnCount = 2
'Set column widths
.ColumnWidths = "50;100"
'Insert the range of data supplied
.List = rngSource.Cells.Value
End With
End Sub