Running Check box code after Command button Click

Private Sub CommandButton1_Click()
Call CheckBox2_Click
End Sub

I have code like the following and it works almost like I 
want it to, but when I check the checkbox it will activate 
the Form worksheet I have.  I do not want anything to 
happen until after the command button is pressed.  What 
can I add or remove to this code to allow this to happen?  
Thanks!

Option Explicit

Private Sub CommandButton1_Click()
Call CheckBox2_Click
End Sub

Private Sub CheckBox2_Click()
Sheets("Form").Activate
ActiveSheet.Range("Address").Select
    If Selection.Interior.Pattern = xlNone Then
    With Selection.Interior
        .ColorIndex = 6
        .Pattern = xlSolid
End With
Else
    With Selection.Interior
       .Pattern = xlNone
End With
End If
End Sub
0
anonymous (74727)
9/15/2004 1:19:24 PM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
600 Views

Similar Articles

[PageSpeed] 19

Maybe just work on the range directly:

Private Sub CheckBox2_Click()
 With workSheets("Form").Range("Address")
    If .Interior.Pattern = xlNone Then
        With .Interior
           .ColorIndex = 6
           .Pattern = xlSolid
        End With
     Else
        With .Interior
           .Pattern = xlNone
        End With
     End If
 end with
End Sub

If you really meant that you didn't want to have the sub run when you clicked on
the checkbox, then don't use checkbox2_click inside your worksheet module.

Move your code to a general module and call it something else.  (Actually, you
could use the same name--but it might get confusing why it's in a general module
in a week or two.)



Todd wrote:
> 
> Private Sub CommandButton1_Click()
> Call CheckBox2_Click
> End Sub
> 
> I have code like the following and it works almost like I
> want it to, but when I check the checkbox it will activate
> the Form worksheet I have.  I do not want anything to
> happen until after the command button is pressed.  What
> can I add or remove to this code to allow this to happen?
> Thanks!
> 
> Option Explicit
> 
> Private Sub CommandButton1_Click()
> Call CheckBox2_Click
> End Sub
> 
> Private Sub CheckBox2_Click()
> Sheets("Form").Activate
> ActiveSheet.Range("Address").Select
>     If Selection.Interior.Pattern = xlNone Then
>     With Selection.Interior
>         .ColorIndex = 6
>         .Pattern = xlSolid
> End With
> Else
>     With Selection.Interior
>        .Pattern = xlNone
> End With
> End If
> End Sub

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10083)
9/15/2004 9:46:28 PM
Reply:

Similar Artilces:

Need only one DLL instance to run...
Hi all, 1: if two apps load the same DLL - LoadLibrary(...) - system will create to different instance of the DLL... Now, in my DLL i've a CList and i need it to be visible to all instance and all apps!!!! Is there a way!? 2: I need the dll to remain loaded till machine reboot!!! Is it possible!? Thanks Ale >if two apps load the same DLL - LoadLibrary(...) - system will create to >different instance of the DLL... >Now, in my DLL i've a CList and i need it to be visible to all instance and >all apps!!!! > >Is there a way!? It'll be difficult to share a ...

Excel combo box
Is there an easy way to maintain a date format from the original cell through selection via a combo box? --- Message posted from http://www.ExcelForum.com/ If you add the items yourself--instead of using listfillrange, then the combobox from the control toolbox toolbar will keep the formatting: Option Explicit Private Sub Worksheet_Activate() Dim myCell As Range With Me.ComboBox1 .ListFillRange = "" .Clear For Each myCell In Me.Range("a1:a14").Cells .AddItem myCell.Text Next myCell End With End Sub or if you want...

credentials to run this report are not stored
Hi all, I'm getting this problem when I try and create a timed subscription. Error: ...credentials to run this report are not stored..... ok I created another folder under the same folder where I'm having this problem. loaded the report and I have no problem. I even moved the current folder with that report in it. Creted another folder with the same name and still the same problem with that named folder. With a different name for the folder I have no problem??? I'm stuck here.. almost all post just talk about storing the credentials, Already done and works...

in box header telephone bent arrow and envelope
messages in inbox: those with a telephone, bent arrow, and an envelope will not open, I cannot delete. I can read them from web mail, but I want to down load and/or delete. any help out there? what type of email acct do you have? is outlook online? -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange ...

xp desktop and start button missin
cant get into to windows even in safe mode have to go to task manager to open anytgin In task mgr,locate "new task",type: cmd In cmd type: CHKDSK C: After,you may want to type: Sfc /Scannow Install xp cd,exit the menu page.Once its thru,remove xp cd,type: CHKDSK C: /F Agree to restart,type: EXIT Restart pc. "jen" wrote: > cant get into to windows even in safe mode have to go to task manager to open > anytgin ...

Size of buttons in toolbar
Hi; I want to have different size of buttons in the same toolbar. The default size is 16x15, but I want to have buttons of this size and some other of 32x15. I've read the article in MSJ, but what I understand is that this way tou change all the buttons to the same size. I even downloaded the source and all the buttons have the same size, so, that is not what I'm looking for. Any idea, or anyone who let me know if I'm wrong? Thanks Dalton Could you just resize the other buttons, but leave bitmaps towards one side or the other? Or, could you have two toolbars (one with smal...

run time error 10-22-03
I am having a lot of trouble when I open up word I get run time error 52 in VB. I have tried uninstalling word and reinstalling it. WE have tried deleting the macro but still to no avail can someone help me please? ...

Repost: Error running Report in an Access 2003 db from Access 2007
Ok, clarification - ignore the code from my original post, some of the reports do work. The ones that don't are reports that I have being filtered. Here is the code from one of those buttons: Private Sub Ok_Click() On Error GoTo Ok_Click_Err 'using the customer sub form for customer state report to filter the report, clicking ok will open report for selected state Dim stDocName As String Dim stLinkCriteria As String If Not IsNull(Me.Search_Results) Then stLinkCriteria = "[StateOrProvince] = """ & Me![Search Results] & """"...

Excel Validation Drop Down Box
Is there any way to increase the size of the text in the validation drop down box? If the sheet is zoomed to say 60% the text in the box is not readable. No, but you may find this helpful: http://www.contextures.com/xlDataVal08.html#Larger In article <0a4c01c3999c$92878a10$a001280a@phx.gbl>, "Mike S." <anonymous@discussions.microsoft.com> wrote: > Is there any way to increase the size of the text in the > validation drop down box? If the sheet is zoomed to say > 60% the text in the box is not readable. ...

Combo box multi autocomplete
Hi am very new to access and am making fair progress, but have struck a problem. I have a database with an old existing table and am creating a new table and form for it. On the new form I want to combo box select a value (say name) from the old table and have it auto complete other fields (say customer number, telephone number, address) on the form and store these into the new table under slightly different column names. Any direction would be much appreciated.. Why would you want to store the data redundantly? That's seldom a good idea. In any case, remember that your combo box can co...

Automatically run macro
My name is Mike and i have a question about microsoft excel macro's. Attached is a copy of the excel sheet im working on. Below the excel sheet is the macro I built. Some of the cells contain given values and some cells are calculated from formulas. Cell (G4) is my given value...it is related to cell (C32). The point is, I plug a value into cell (C10) and it runs through the rest of the calcs in the other cells and gives me a value to cell (C32). I built a macro that works as a goal seek pretty much. The macro makes cell (C32) equal to cell (G4) and gives me the value for cell (C10). I wan...

Excel Continuous Running Total
I posted a message earlier and have received a partial solution. I want to keep track of how much stock prices go up or down with a running total of how much they go up or down over several days until the direction changes. For example, if price go up 10 on Mon, 20 on Tues, 30 on Thurs and down 10 on Fri I want my running total column to show a positive number of 60 and then a red number of 10 and continue adding the amount of the total of the down days until the market shows an up day. The formula I am now using total the first and second day but does not do a running total count if t...

display changing label caption on form as sub runs w/o screen flic
let's say i have this routine Sub Test label1.caption = "Starting ... " 'do events label1.caption = "Getting there ... " 'do events label1.caption = "Finished! ... " End Sub on my form, i have label1 right in the middle what happens is sometimes the message will change, and then sometimes it wont, or it will show the first one, skip the second and jump to the third etc etc etc so it is inconsistent. is there a way to make sure the label caption displays consistently, on time, wh...

Locate a cell, based on a criteria, then use the 'Cell' command...
I am using a pivot table to configure some data. In the first column, the pivot table of course displays only one instance of the text representing of data group. What I need to do is determine in which cell a particular item of text (i.e. the criteria) resides in. Once I can locate the cell where my 'criteria' text string resides, I can then use the CELL function to return the row number. My question is... what excel formula can I use to locate a cell in a single column range, where the cell contains the text = "XYZ" My eventual plan is to then use the following ...

How to write code to check if MSFlexGrid.ocx was registered
I'm using msflexgrid. How do I write code to check to see if the client computer has msflexgrid.ocx register (or class CMSFlexGrid is not available), because if not I need to do something else Thanks! You may want to use CoCreateInstance to see if it exists. You'd get a REGDB_E_CLASSNOTREG code if it doesn't. <jkclub2000@yahoo.com> wrote in message news:1139278012.177028.199980@z14g2000cwz.googlegroups.com... > I'm using msflexgrid. How do I write code to check to see if the client > computer has msflexgrid.ocx register (or class CMSFlexGrid is not > availa...

Move Mail box failed
Dear all, When I try to move a mailbox accross Exchange 2000 server (or accross different mail store in same server), I got below errors. Is the problem caused from System Attendant mailbox? Because I found the Last Logon of SA mailbox is Domain/System in this server, for the other server which can normally opration the last logon of SA mailbox is Domain/Admin Thanks for help. MSExchangeAdmin Error Move Mailbox 1008 N/A EXCH1 Unable to move mailbox 'Test'. Error: The attempt to log on to the Microsoft Exchange Server computer has failed. The MAPI provider failed. Microsoft Excha...

Money 2002 will not run
I had been using Money 2002 for approx. 3 yrs on my home pc (Dell Dim 2100, XP Home Ed. w/SP2). Last year, it simply would not launch. No error message, no splash screen, no app opening, no process listed in Task Manager. Just.... nothing.... The only change that was made to the system since M2k2 last ran was upgrading my a/v solution from Trend Micro PC-Cillin to TM Internet Security. I have tried disabling every aspect of the Internet Security product, as well as completely un-installing the app, and then attempting to run Money, but the same thing (nothing) happens. I was considerin...

Check names in Outlook 2003 Calendar
Recently upgraded from Outlook 2000 to Outlook 2003. Before, when I created an appointment in Calendar it would automagically check the name against Contacts. It is no longer doing this. Is there an option to change this? How do I link up my Contacts so Calendar checks the names? Thanks for any help. What do you mean that it would check the names against contacts? Do you mean auto-resolve/complete? If yes, then you need to build your auto-complete cache for it to start working again. It does not use the Contacts folder or Address Book to build this cache but builds it based on...

MS Point of Sale 2.0
For opening and closing amounts, we keep a set amount of cash in the drawer. During business, cash and checks are accepted. At the end of day, we are doing a "drop" of the amount of cash AND checks added together (since POS does not have a position to do "check drop". We still balance overall but the z report indicates the overage/shortage of the check amount in the close section. Is this the correct way to close? Should there be position to enter the amount of checks that we are dropping? If we leave the amount of checks in the closing amounts window, will POS ...

Re: Workflow just wont run automatically, i have to run them manually
Yes, but i realized what i was doing wrong. I assumed [bad idea] that if i create a case and hit Save & Close the first time, taht the rule will run. In order for the rule to run automatically, it has to be Save, once it saves it, then Save & Close. Thanks for your reply. "Hi, Did you check the workflow monitor to see if the rules get triggered correctly and complete sucessfully ? Have a nice day, St=E9phane Dorrekens " --------------= Posted using GrabIt =---------------- ------= Binary Usenet downloading made easy =--------- -= Get GrabIt for free from http://...

Outlook Still Running
I am running XP Pro with Office 2003 Pro and sometimes when I exit out of Outlook, Outlook.exe and Winword.exe stay as processes still running. Does anyone else have this problem and what can do to make sure this does not happen? Thanks for your help -- Neil Remove ABCD from Email address to reply <neil154ABCD@earthlink.net> wrote: > I am running XP Pro with Office 2003 Pro and sometimes when I exit > out of Outlook, Outlook.exe and Winword.exe stay as processes still > running. Does anyone else have this problem and what can do to make > sure this does not happ...

Great Plains 6 Country Codes
I am trying to extract country codes from a Great Plains 6 SQL backup with: select SLSTERCD from RM20101 This gives me a set of good results in 7.5 and they aer nearly ISO compliant so I can work out where they relate to. However, in version 6 the results are not even close. They come back as: " " "1" "2" "RDCO" I can;t find a lookup table anywhere which can decipher these results. Is anyone able to point me in the right direction? SLSTERCD is the sales territory ID - these are created by users and can be anything you want, they don't have to...

Publisher 2000 will not run
I had problems with Publisher 98 not running which we=20 never did solve so I installed office 2000 to see if=20 Publisher 2000 would function. Same problem: The flash=20 screen pops up and then disappears. No program. Microsoft=AE Publisher 2000 Version 6.0 has encountered a=20 problem and needs to close. We are sorry for the=20 inconvenience. Howard, hi again, Have you tried opening Publisher in safe mode? Publisher retains all printer information within its publications. If you can open Publisher in safe mode, either regress or update your printer and video drivers. -- Mary Sauer MS MV...

Combo box 03-08-07
Please help! I created a combo box called, "cmbLocation" and a look up table called, "tblLocation". I would like to set a rule for the combo box cmbLocation that allow the user to select an item from the list(tblLocation) once time only else it will pop up a message said, "Duplicate entry". what I meant is that the item on the tblLocation can only be used 1 time. THANK YOU! -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200703/1 What are you doing with the item once it is selected? Assuming it's being...

Very strange problems while running Great Plains on workstations
I notice that a few workstations in an office I support are having problems when they run Great Plains. Excel, Outlook, Word and Dynamics.exe are showing in the Application event log as being Hanging or Faulting. I also see Fault Bucket errors, but when I search online I cannot find any information online. Here is one of the Fault Bucket errors: 3:15:35 pm 28-Sep-06 Application Hang None 1001 N/A Fault bucket 296734104. Also, these workstations are experiencing problems printing PDF files. Has anyone out there seen this behavior and if so, how can these problems be fixed? Thank you, ...