Hey All,
I have a Piece of code that when a form is initialised it runs. I Want the code to find if there is a value in the current cell selected and if there is load the form if not dont load the form.
This is the code that i have produced:
The Problem is that it works fine if the "Unload PRICE_CHANGE" isnt in there but the error #91 "Object Variable or With Block Variable not Set"Code:Private Sub UserForm_Initialize() Dim Target As Integer Let Target = Selection.Value If Target = 0 Then MsgBox Prompt:="PLEASE SELECT AN ITEM", Buttons:=vbOKOnly + vbInformation Unload PRICE_CHANGE End If End Sub
I have tried a number of ways to overcome it but just cant get it to work.
any help will be great. Thanks
Tom
What is PRICE_CHANGE and why are you trying to unload it?
This error basically meant that VBA has no idea what object you're trying to do things to!
Hello Tom,
Move your code from the UserForm_Initialize() event to the UserForm_Activate() event code module.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks