How can I change this code so that it won't run if the text box SerialNumber equals 'none'?
Please Login or Register to view this content.
How can I change this code so that it won't run if the text box SerialNumber equals 'none'?
Please Login or Register to view this content.
Hi
A ssuming the TextBox is on the Equipment Data sheet perhaos
Please Login or Register to view this content.
Richard Buttrey
RIP - d. 06/10/2022
If any of the responses have helped then please consider rating them by clicking the small star icon below the post.
Im getting run-time error '438', Object doesn't support this property or method.
The Text box SerialNumber is located on a Userform called NewItem, and the code is ran from a command button on that user form.
Also to verify it should be preventing the code from running when the text in the text box says none (not blank).
Would this work?
Please Login or Register to view this content.
Here's an alternative if you want it to prevent from running and unload when the TextBox named SerialNumber is blank:
Please Login or Register to view this content.
Hi nitefox,
I would check the textbox before trying to populate the EquipmentData sheet i.e.
HTHPlease Login or Register to view this content.
Robert
____________________________________________
Please ensure you mark your thread as Solved once it is. Click here to see how
If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post
The code just ran as normal. When I type in the word NONE, it should be stopping the code from running so it doesn't add the text box values to the worksheet. Currently when I type in the word NONE it is still adding it to the workbook.
That last code came up with Compile Error: End if without block if.
Try this which incorporates your second requirement:
RobertPlease Login or Register to view this content.
Last edited by Trebor76; 12-20-2013 at 08:16 PM.
It is still allowing the code to run when I type in none. I think you are misunderstanding me to believe I mean a blank text box, but I literally mean the word none is typed into the text box.
Also I just realized I need to make a slight change, rather than doing nothing when the word NONE is typed into SerialNumber, it should instead enter the value of the text box ItemDescription into active cell -1,-1.
Please Login or Register to view this content.
Thank you mehmetcik, that stopped it from adding the data to the worksheet, however I would like it to then enter the value of the text box ItemDescription into active cell -1,-1, and close the Userform NewItem.
No, I understood you as that what the code doesI literally mean the word none is typed into the text box
Sorry Trebor i somehow missed your last post. Thank you that code worked, in that it prevented it from adding the text box values to the worksheet. I am also looking to perform the following (just when none is entered):
Enter the value of the text box ItemDescription into active cell -1,-1, and close the Userform NewItem.
In any other case (when none is not entered) it should run the original code.
No problem. As long as the activecell is not in column A the following code for the none value should work:
RobertPlease Login or Register to view this content.
When SerialNumber is equal to none it came up with run time error 438, Object doesn't support this property or method on this line:
The active cell is in the G column on the ReturnData page.Please Login or Register to view this content.
You're not giving us all the information needed to provide an answer!! You didn't say anything about returning any value to any other tab besides EquipmentData which in this case has caused the error as you cannot reference an activecell outside the activesheet.
Try this work around, which besides column A will not work from within row 1:
RobertPlease Login or Register to view this content.
Thank you Trebor that did it. I apologized I didn't realized I had not specified the worksheet.
No problem - I'm glad we've been able to solve it for you.
Thanks for marking the thread as solved and for adding to my reputation
Robert
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks