Run Time Error When Calling Userform
Jan 16, 2007
I am getting a run time error # 9 when I run a macro that calls a Userform or when I try to run code in a Userform module. The code performs beautifully on my computer, but it did not work on a coworker's computer. It ended up working on 3 out of the 5 computers I have tried it on.
I have tried changing security settings to low, and a bunch of other stuff, but I cannot get the code to run on the computers that get the run time error on them when I try running the code on them.
I get the run time error when I try to load or show any userform in the workbook and I get it if I try to run code that is in the userform module. However, if I paste the code into a regular module and run it, the code runs fine.
Does anyone know what could be causing this? I don't think my code is causing the problem since it runs on some machines, I am guessing there is a setting that is preventing Excel from calling Userforms.
I have a button, Private Sub CommandButton1_Click, on a sheet that shows a userform. This is the bit of code that gets tagged with the run time error. The userform has a refedit control on it allows the user to select a cell and then hit ok to run the code or cancel to, well, cancel it.
Code for the button that gets tagged with the run time error:
Private Sub CommandButton1_Click()
frmLoadTrade.Show 'calls userform
End Sub
Code in the Userform Module:
Private Sub cmdCancel_Click()
TradeTicketSpreadsheetName = ThisWorkbook.Name
Unload Me
Workbooks(TradeTicketSpreadsheetName).Activate
End Sub
View 4 Replies
ADVERTISEMENT
Feb 5, 2008
I get a "Run-time error '9': subscript out of range" error when calling a userform.
The code opens a reference spreadsheet then shows a userform with a combobox and two command buttons (Continue and Quit). The userform has a private initialization sub-routine to populate the combobox with values from a list on the reference spreadsheet. When the userform is called the error comes up.
Here's my problem: The code was written on my computer and saved as an Add-in. The add-in has since been installed on a number of other computers and works properly. Recently I tried to run the code and this error started popping up, don't know what changed. All versions of Excel are the same and haven't changed.
BRF = ActiveWorkbook.Name
If BRF = "Blank upload.xls" Then
Workbooks.Open path & "QC Data AnalysisQCDA ref.XLS"
OtherBRF.Show
Workbooks("QCDA ref").Close SaveChanges:=False
Goto 1
End If
View 5 Replies
View Related
Dec 5, 2007
I call a userform from a sub menu i created it, but i got an error 449: Argument not optional.
Private Sub Workbook_Open()
Dim cControl As CommandBarPopup
On Error Resume Next 'Just in case
'*Delete existing Super Menu if it was left.
Application. CommandBars.FindControl(Tag:="MyMainMenuTag").Delete
On Error Goto 0
On Error Goto u
'*Add new Accounting Menu
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add(msoControlPopup, 1, , , True)
With cControl...........................
View 7 Replies
View Related
Aug 2, 2014
I'm getting a 'Run Time Error 91' saying that 'Object Variable or With Block not set'.
Error lies here:
Code:
Me.lstCategpry.Column = CustRec.GetRows(Fields:=Array("name"))
Userform Initialize:
Code:
Private Sub UserForm_Initialize()
[Code].....
View 4 Replies
View Related
Oct 22, 2008
I included a couple screen prints showing that the form exists, and that it is not misspelled in the code. What should I look for?
View 4 Replies
View Related
Dec 10, 2008
I need to make the Red X at the top firght of my user form "End" rather than "Exit Sub" which I think it is trying to do now, as simply exitting the sub returns it to the previous sub which opens the form again.
View 4 Replies
View Related
Aug 13, 2007
Hi, i'm having a terrible problem (at least for me).
I want to use a var from a UserForm to use it in calculation method in a Module.
How can i refer to that variable in the Userform in the Module code?
View 11 Replies
View Related
Nov 17, 2013
I met problem in calling into a subroutine. It is error 424. I have dim all variable. However I still get it.
Code:
Sub UpdateAll()
'
' UpdateAll Macro
[Code]....
I got the error when I pressed F8 to step into the getOneRecord() function, which is highlighted in red.
View 2 Replies
View Related
Nov 21, 2009
I can't find anything direct via the web and here so I will ask what will hopefully be an easy question.
I have a form called FIELD_MX and on this form I have a Command Button called Enter ONT Demand Requirements.
When I click the Enter ONT Demand Requirements, I want to display a form called ONT_Demand_Requirements.
I know the UserForm needs to be initialized, but where should it be or am I wrong?
View 9 Replies
View Related
Dec 19, 2006
the spreadsheet needs to be copied to a directory called "C:downloads" as it contains a ODBC query to itself (In reality, this is a query to an External Oracle Database)
On loading, it should pop up a simple userform, with a combo and two command buttons, which when pressed takes you to a (hidden) tab that displays a pivottable.
All works well until I try to close /save when 60% of the time, Excel encounters problems and closes and will not load up the file the next time until either quit excel or disable macros. Messages include "file/path access error", "I/O Error" or get restarts excel.
On a casual run through, I expect you might report back that "All worked ok for me". Please can you give it a bit of a thrashing, comment out the userform show, save the file (frequently) becuase i assure you it will break ultimately!
This is a brand-new file and I've tried it on about 5 different PC running different versions of Excel and generally get the same result.
View 7 Replies
View Related
Oct 8, 2008
I have written a Excel (2003) that searches a worksheet for a string in any cell. If the string is not found, it uses the 'On Error GoTo' command to jump to a given label. It works fine on the first string not found. When it searches for the next non-existent string, it fails with:
'Run-time error '91':
Object variable or With block variable not set'
Do I have to clear a buffer after each cells.find search?
My
View 7 Replies
View Related
Dec 24, 2008
I have a userform that has a time field on it and then the userform displays the time as a number.
Ex. I entered 11:00 AM in the Time of Contact field and the form displays it as 0.458333333333333.
View 10 Replies
View Related
Jun 19, 2014
I have a userform that time stamps on my userform as soon as i open the form, is there a way that when I submit, that the amount of time that I was on the call to be put in my column on my worksheet as minutes?
View 2 Replies
View Related
Oct 10, 2006
I'm not sure why this is happening, but every other time I run this one specific macro, I get a "Run-time error '1004': Paste method of Worksheet class failed". I even tried running this macro, then running a different one, then running this again, but I still got the error every other time.
Every time I get the error, it highlights this line of
Sheets("Regenerate Request").Paste
This is all of the code up to where I get the error:
Sub YesRegen()
' after user has hit Yes on the RegenerateRequest macro, this posts the new request to
' the log, generates the new file and attaches it to an email
Application.Run "LogUnprotect"
Range(Range("A" & ActiveCell.Row), Range("K" & ActiveCell.Row)).Copy
'Selection.Copy
Sheets("Regenerate Request").Activate
Application.Run "RegenFormUnprotect"
Range("A40:K40").Select
Range("A40").Activate
Sheets("Regenerate Request").Paste
View 10 Replies
View Related
Jun 17, 2006
I am attempting to pick up a date with time entry on a worksheet and place it into a TextBox on a UserForm. Format on the sheet is mm/dd/yyyy h:mm AM/PM. The UserForm is placing the value as mm/dd/yyyy 12:00 AM. here is the
Private Sub UserForm_Initialize()
If Not Range("dDate").Value = "" Then
TextBox2.Value = Range("dDate").Value
TextBox2.Text = Format(DateValue(TextBox2.Text), "mm/dd/yy h:mm AM/PM")
Else
TextBox2.Value = ""
TextBox2.SetFocus
End If
End Sub
"dDate" is the named range where the date is sitting. The format is also set on the TextBox2 exit event. Can anyone see why only the date portion is being transfered with the default 12:00 AM for no time component of the value?
View 3 Replies
View Related
Mar 5, 2013
I have a relatively complex report that I work with and a worksheet is no longer required. I have deleted the worksheet and reference to it hwoever when running the macro to pull all the data, it gets to the summary of all the data and i get the Run Time Error 1004 Application-defined or object-defined error pop up. ON reviewing it, it is on this line ActiveCell.Offset(0, 0).Range("a1:a" & Range_Height).Select of the below code...
VB:
Sub GetRangeName()
Sheets("TOTAL").Select
[Code].....
use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window.
View 1 Replies
View Related
Apr 26, 2009
I have a simple function below to put in different forumlas in different cells to get stock quotes. When I run this I get runtime error 1004 application-defined or object-defined error. The first formula goes through but vba chokes on the next formula: ActiveCell.Offset(I - 1, 4).Formula = username
View 10 Replies
View Related
Aug 12, 2009
Run-time error '1004' Application-defined or object-defined error. I am trying to use this
View 2 Replies
View Related
Oct 4, 2009
I was trying to use the below code
View 4 Replies
View Related
Aug 17, 2008
For some reason my form won't open when the workbook is opened. I get an error message "run time error '424' object required" (which happens when I have Form1.show in the BOTH workbook_open event and the userform_initialize event (oops)). When I removed form1.show from the userform_initialize I don't get an error but I also get no form. I recall having this issue before but I can't recall how to fix it.
Can I call the userform_initialize event from the workbook open event to get around this successfully and properly?
View 9 Replies
View Related
Dec 4, 2009
I keep getting a Run Time Error 1004 (Application Defined or Object Defined Error) when my sub reaches this line:
ActiveCell.Formula = "=SUM(D222,D224,D226,D227,D229,...)"
In the actual line of code the "..." above is another 20-30 or so cells in column "D". Probably no more than 150-170 characters in the line.
If I remove half of the cell range names it works, but I need all of the cell ranges for the equation.
View 9 Replies
View Related
May 9, 2008
have a look at this and tell me why i cant even give it a trail run without getting an error
[url]
View 13 Replies
View Related
May 11, 2009
I keep getting an Run-time error '424': Object required error whenever I try to run a macro with a rather involved user form. I know the code for the form is what is keeping it from running properly. Here is the code for the form:
View 6 Replies
View Related
Sep 2, 2009
I have a userform that is working perfectly, but when I try to make it an add-in I can't even get it to load. When loading the userform as an add-in I get the error "Run error nr. '9'.: The Index is out of the interval" (freely translated from Swedish to English). The code I'm using to load the userform is
View 3 Replies
View Related
Oct 20, 2011
I have an application using two userforms. Following sequence is used:
1. Open Userform1 (with uf.show)
2. click on a commandbutton in userform1 opens a second userform on top of userform1.
3. Close userform2 with commandbutton on userform2 (userform2.hide)
(I did not want the user to close the UF via the "X" )
Runtime error 402 : Must close or hide topmost modal form first
So, I changed my code so when the user clicks the commandbutton in userform2
userform1.hide (which is the topmost)
userform2.hide
But again I get the same error.
View 7 Replies
View Related
Aug 5, 2008
I created a UserForm (userform1) and added a label to it which essentially just says: "Pick a Colour"...
The other UF controls are added on the fly using the below code...however when I try to add the event to each button I get the Automation Error but I don't really understand how / why... the events are actually added to the VB project ok...
Private Sub UserForm_Initialize()
Dim NewButton As MSForms.CommandButton
Dim ws_i, line As Integer
Dim clr_str As String
For Each ws In ActiveWorkbook.Worksheets
I added a dummy routine for test purposes which is to be invoked on click of UF button control (I have tried placing this code in a standard module, within UF module etc to no avail):
Sub HIDE_WS(clr_id As Long)
MsgBox clr_id
End Sub
So to reiterate -- when I invoke the initialisation of the UF I get the following error:
Automation Error
The object invoked has disonnected from its clients
All events are added for each control.
If I remove the adding of the events I know the UF populates with the correct controls etc...
View 9 Replies
View Related
Jan 20, 2010
When I click on the userform that opens when the workbook does I get this error:
Run-time error '13':
Type Mismatch
This is the code highlighted
DT=UserForm1.TextBox3.Text
View 9 Replies
View Related
Feb 17, 2010
The initialization code of a userform I'm using has started causing me 'Runtime Error 13, Type Missmatch' and I can't figure out why. Can anyone see a reason why I may be experiencing this,
Private Sub UserForm_Initialize()
'Get Last Entry
Dim countnonblank As Integer, myRange As Range
Dim SDate As Date, SDateRange As String, EDate As Date
Dim SDateString As String, EDateString As String, DirString As String
'count cells with data in them
Set myRange = Sheets("textfilemerger").Range("A:A")
countnonblank = Application.WorksheetFunction.CountA(myRange)
'decide if data is present or not
If countnonblank = 1 Then.............................
View 9 Replies
View Related
Jul 4, 2006
I am populating a UserForm from some ranges on my workbook. All is well EXCEPT for the third guy down- "lstCheckDep". The only difference I can figure out is that the cell it is drawing from has a date format. How can I adjust for this so that it's contents can go on the UserForm, without getting hung up on the formatting?
Private Sub UserForm_Initialize()
lblCandidate.Caption = Range("Rcandnam").Value & " - #" & Range("ID").Value
lstCheckCntry = Range("RCountry").Value
lstCheckDep = Range("RDeparture").Value
lstCheckTrack = Range("rTrack").Value
lstCheckLang = Range("Lang").Value
End Sub
View 4 Replies
View Related
Feb 20, 2008
I've created a userform on one computer which launchs when I open the excel workbook. The userform contains comboboxs and a picture. But when i saved it on another computer and tried to open it and it errors. (Run-Time error 9). (Still works fine on the computer that created it). All references are to this workbook only. Userform is contained within the Forms folder of this workbook(not personal.xls) and the userform name is PDM_SPLASH1. Also, if i go into VBA I can see the form, but it wont launch when i try to play in manually. (Run-Time error 9)
Private Sub Workbook_Open()
Worksheets("Launch Page").Select
Worksheets("Instructions").Visible = False
Worksheets("SelectDB2").Visible = False
Worksheets("REPALIGNMENT").Visible = False
Worksheets("PDM").Visible = False
Worksheets("TABLES").Visible = False
Worksheets("DISPENSING").Visible = False
Worksheets("DISPENSED").Visible = False
Worksheets("OpportunityAnalysis").Visible = False
Worksheets("ENGINE1").Visible = False
Worksheets("POTENTIALCONTRACTLOSS").Visible = False
PDM_SPLASH1.Show
End Sub
View 2 Replies
View Related