![]() |
Type mismatch error only on the first run
Hi!
I have a userform and i initialize it with the code shown below. The userform is set to show on workbook open. I get 2 consecutive "Type mismatch" errors when the workbook opens. I cant seem to locate the error. Note: this happens only in Excel 2007. The code was originally written in Excel 2003 and has no errors running there. Please help! Thank you! Martin Private Sub UserForm_Initialize() ActiveWorkbook.Sheets("START").Select Application.ScreenUpdating = False Application.Run "USER.xls!visible" ActiveWorkbook.Sheets("Deltagere").Select Range("A2").Select Do If IsEmpty(ActiveCell.Value) = False Then cboProjektleder.AddItem (ActiveCell.Offset(0, 1).Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveWorkbook.Sheets("Deltagere").Select Range("M1").Select If ActiveCell.Value = 0 Then Me.MultiPage1.Pages(4).visible = False Me.MultiPage1.Pages(5).visible = False Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 1 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = False Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 2 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = True Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 3 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = True Me.MultiPage1.Pages(6).visible = True End If With NoegleInit ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With With NoegleInit2 ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With With NoegleInit3 ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With tid = Array("2", "4", "6", "8") For Each mask In tid mandagtid1.AddItem mask tirsdagtid1.AddItem mask onsdagtid1.AddItem mask torsdagtid1.AddItem mask fredagtid1.AddItem mask mandagtid2.AddItem mask tirsdagtid2.AddItem mask onsdagtid2.AddItem mask torsdagtid2.AddItem mask fredagtid2.AddItem mask ComboBox1.AddItem mask ComboBox2.AddItem mask ComboBox3.AddItem mask ComboBox4.AddItem mask ComboBox5.AddItem mask ComboBox6.AddItem mask ComboBox7.AddItem mask ComboBox8.AddItem mask ComboBox9.AddItem mask ComboBox10.AddItem mask ComboBox17.AddItem mask ComboBox18.AddItem mask ComboBox19.AddItem mask ComboBox20.AddItem mask ComboBox21.AddItem mask ComboBox22.AddItem mask ComboBox23.AddItem mask ComboBox24.AddItem mask ComboBox25.AddItem mask ComboBox26.AddItem mask Next Application.Run "USER.xls!veryhidden" Application.ScreenUpdating = True Me.MultiPage1.Value = 0 cboProjektleder.SetFocus ActiveWorkbook.Sheets("START").Select End Sub |
Type mismatch error only on the first run
.... Oh yes, and the error doen't reapear if I excecute the code
manually afterwards... |
Type mismatch error only on the first run
Can you tell us which lines are the ones causing the error?
Bob Flanagan Macro Systems 144 Dewberry Drive Hockessin, Delaware, U.S. 19707 Phone: 302-234-9857, cell 302-584-1771 http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "mlcs" wrote in message ... Hi! I have a userform and i initialize it with the code shown below. The userform is set to show on workbook open. I get 2 consecutive "Type mismatch" errors when the workbook opens. I cant seem to locate the error. Note: this happens only in Excel 2007. The code was originally written in Excel 2003 and has no errors running there. Please help! Thank you! Martin Private Sub UserForm_Initialize() ActiveWorkbook.Sheets("START").Select Application.ScreenUpdating = False Application.Run "USER.xls!visible" ActiveWorkbook.Sheets("Deltagere").Select Range("A2").Select Do If IsEmpty(ActiveCell.Value) = False Then cboProjektleder.AddItem (ActiveCell.Offset(0, 1).Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveWorkbook.Sheets("Deltagere").Select Range("M1").Select If ActiveCell.Value = 0 Then Me.MultiPage1.Pages(4).visible = False Me.MultiPage1.Pages(5).visible = False Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 1 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = False Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 2 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = True Me.MultiPage1.Pages(6).visible = False ElseIf ActiveCell.Value = 3 Then Me.MultiPage1.Pages(4).visible = True Me.MultiPage1.Pages(5).visible = True Me.MultiPage1.Pages(6).visible = True End If With NoegleInit ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With With NoegleInit2 ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With With NoegleInit3 ActiveWorkbook.Sheets("Bookings").Activate Range("A3").Select Do If IsEmpty(ActiveCell.Value) = False Then .AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True End With tid = Array("2", "4", "6", "8") For Each mask In tid mandagtid1.AddItem mask tirsdagtid1.AddItem mask onsdagtid1.AddItem mask torsdagtid1.AddItem mask fredagtid1.AddItem mask mandagtid2.AddItem mask tirsdagtid2.AddItem mask onsdagtid2.AddItem mask torsdagtid2.AddItem mask fredagtid2.AddItem mask ComboBox1.AddItem mask ComboBox2.AddItem mask ComboBox3.AddItem mask ComboBox4.AddItem mask ComboBox5.AddItem mask ComboBox6.AddItem mask ComboBox7.AddItem mask ComboBox8.AddItem mask ComboBox9.AddItem mask ComboBox10.AddItem mask ComboBox17.AddItem mask ComboBox18.AddItem mask ComboBox19.AddItem mask ComboBox20.AddItem mask ComboBox21.AddItem mask ComboBox22.AddItem mask ComboBox23.AddItem mask ComboBox24.AddItem mask ComboBox25.AddItem mask ComboBox26.AddItem mask Next Application.Run "USER.xls!veryhidden" Application.ScreenUpdating = True Me.MultiPage1.Value = 0 cboProjektleder.SetFocus ActiveWorkbook.Sheets("START").Select End Sub |
All times are GMT +1. The time now is 11:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com