Fault when launching a user form

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
:(I have taken advice on this point previously and have managed to get the userform to load ( Many Thanks ) but i am having problems where i need a comboxbox to give several options ( Error highlighted in red below ). This will re occur as the user form when it loads has 3 options where the data can come from.

Also where the form can load is there anyway i can have a password option set for each one? If so how would i go about this? :confused:


Rich (BB code):
Private Sub cmdsubmit_Click()
'Open file
Workbooks.Open Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\Data.xls"
Dim myBook As Workbook
 
On Error Resume Next
Set myBook = Application.Workbooks("Data.xls")
On Error GoTo 0
 
'If Ash Longman - Call Centre Enquiry
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Ash Longman")
If UserForm2.ComboBox1 = "Ash Longman" Then
ActiveWorkbook.Sheets("Ash Longman").Activate
 
Unload Me
 
UserForm1.Show False
For i = 3 To 65000
    If Cells(i, 1) = "" Then Exit For
    If Cells(i, 11) = "" Then
        UserForm1.txtdate.Value = Cells(i, 1)
        UserForm1.TextBox1.Value = Cells(i, 2)
        UserForm1.TextBox2.Value = Cells(i, 3)
        UserForm1.TextBox3.Value = Cells(i, 6)
        UserForm1.TextBox6.Value = Cells(i, 4)
        UserForm1.TextBox5.Value = Cells(i, 5)
        UserForm1.TextBox4.Value = Cells(i, 7)
        UserForm1.TextBox7.Value = Cells(i, 8)
        UserForm1.TextBox8.Value = Cells(i, 9)
        UserForm1.TextBox9.Value = Cells(i, 10)
         With UserForm1.JEN.Value
             UserForm1.AddItem "No"
            UserForm1.AddItem "Yes"
         End With
 
         With CBoxAdd
 
             .AddItem "Gavin Mazza"
            .AddItem "Jeannette Yates"
            .AddItem "Joshim Khan"
            .AddItem "Mark Haslam"
            .AddItem "Mark Taylor"
            .AddItem "Mark Weikert"
            .AddItem "Nicholas Sampson"
             
         End With
         With txtdate
             .Enabled = False
         End With
 
    End If
Next
End If
'If Andy Morrell - callcentre enquiry
If UserForm2.ComboBox1 = "Andy Morrell" Then
ActiveWorkbook.Sheets("Andy Morrell").Activate
 
Unload Me
 
UserForm1.Show False
For i = 3 To 65000
    If Cells(i, 1) = "" Then Exit For
    If Cells(i, 11) = "" Then
        UserForm1.txtdate.Value = Cells(i, 1)
        UserForm1.TextBox1.Value = Cells(i, 2)
        UserForm1.TextBox2.Value = Cells(i, 3)
        UserForm1.TextBox3.Value = Cells(i, 6)
        UserForm1.TextBox6.Value = Cells(i, 4)
        UserForm1.TextBox5.Value = Cells(i, 5)
        UserForm1.TextBox4.Value = Cells(i, 7)
        UserForm1.TextBox7.Value = Cells(i, 8)
        UserForm1.TextBox8.Value = Cells(i, 9)
        UserForm1.TextBox9.Value = Cells(i, 10)
 
    With JEN
        .AddItem "No"
        .AddItem "Yes"
    End With
 
    With CBoxAdd
 
        .AddItem "David Watson"
        .AddItem "John Smith"
        .AddItem "Hannah Hill"
 
    End With
    With txtdate
        .Enabled = False
    End With
    End If
Next
End If
'If Christine Whitty - callcentre enquiry
If UserForm2.ComboBox1 = "Christine Whitty" Then
ActiveWorkbook.Sheets("Christine Whitty").Activate
 
Unload Me
 
UserForm1.Show False
For i = 3 To 65000
    If Cells(i, 1) = "" Then Exit For
    If Cells(i, 11) = "" Then
        UserForm1.txtdate.Value = Cells(i, 1)
        UserForm1.TextBox1.Value = Cells(i, 2)
        UserForm1.TextBox2.Value = Cells(i, 3)
        UserForm1.TextBox3.Value = Cells(i, 6)
        UserForm1.TextBox6.Value = Cells(i, 4)
        UserForm1.TextBox5.Value = Cells(i, 5)
        UserForm1.TextBox4.Value = Cells(i, 7)
        UserForm1.TextBox7.Value = Cells(i, 8)
        UserForm1.TextBox8.Value = Cells(i, 9)
        UserForm1.TextBox9.Value = Cells(i, 10)
 
    With JEN
        .AddItem "No"
        .AddItem "Yes"
    End With
 
    With CBoxAdd
 
        .AddItem "Zenny Asghar"
        .AddItem "Tim Nickson"
        .AddItem "Michelle Hilton"
 
    End With
    With txtdate
        .Enabled = False
    End With
 
    End If
Next
End If
End Sub

All help apppreciated
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Looking at the code at OzGrid, I'm guessing a copy and paste in Firefox? ;)
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top