![]() |
Pretty basic VBA help....if you know how!!
Hello!
Thanks for taking the time to look at this help request. This is the last bit to complete my first Excel project involving VBA! I basically have a button which fires up a macro with a VBA input box into which users are invited to enter an 8 digit code. What I need to do is to say 'If the code entered is the same as the number in Sheet1!A1 then delete the button. If it's not the same as Sheet1!A1 then give a 'that is not the right code' message and stop. Looking at what you guys are writing about I know this should be easy, but I've not yet reached that place where it all starts to click together and self generate. Any advice on books etc that will help me get there? Thanks again...I appreciate your help. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Pretty basic VBA help....if you know how!!
CommandButton from the Control Toolbox Toolbar
Private Sub CommandButton1_Click() res = InputBox("Enter 8 Digit Number:") If CLng(res) = Worksheets("Sheet1").Range("A1").Value Then Application.OnTime Now, "Deletebutton" Else MsgBox "Number is incorrect" End If End Sub Code above should go in the sheet module where the button is located. In a general module put this code: Sub DeleteButton() Worksheets("sheet1") _ .OLEObjects("Commandbutton1").Delete End Sub Commandbutton should be named CommandButton1 - both the name property and the OleObject name. Of course if the workbook is not saved after the delete, the next time you open it the button will be back. -- Regards, Tom Ogilvy Big Chris wrote in message ... Hello! Thanks for taking the time to look at this help request. This is the last bit to complete my first Excel project involving VBA! I basically have a button which fires up a macro with a VBA input box into which users are invited to enter an 8 digit code. What I need to do is to say 'If the code entered is the same as the number in Sheet1!A1 then delete the button. If it's not the same as Sheet1!A1 then give a 'that is not the right code' message and stop. Looking at what you guys are writing about I know this should be easy, but I've not yet reached that place where it all starts to click together and self generate. Any advice on books etc that will help me get there? Thanks again...I appreciate your help. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 01:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com