MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 8th, 2002, 08:45 AM   #1
Arash_The_A_Level_Student
New Member
 
Join Date: Feb 2002
Posts: 38
Default

Hello, I have a problem, I have created a buttons that I would like when clicked to will automatically close and save the application however I would also like it to every 259 times this is done to pop up a message box saying a customised message can anyone please help me?
Arash_The_A_Level_Student is offline   Reply With Quote
Old Mar 8th, 2002, 09:01 AM   #2
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Odd one .

Try naming a cell Counter (on the same sheet as your button) and hiding the column it's in, then paste the following code to the start of your button's code

Range("Counter") = Range("Counter") + 1
If Range("Counter") = 259 Then
MsgBox "This buttonhas been pressed 259 times"
Range("Counter") = 0
End If

' Rest of your code
Mudface is offline   Reply With Quote
Old Mar 8th, 2002, 11:45 AM   #3
Arash_The_A_Level_Student
New Member
 
Join Date: Feb 2002
Posts: 38
Default

Um could you elaborate on this please?
Arash_The_A_Level_Student is offline   Reply With Quote
Old Mar 8th, 2002, 12:04 PM   #4
Mudface
MrExcel MVP
 
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
Default

Sure, but I'll need you to elaborate for me first: -

1. How many worksheets are in your workbook and what are they called?
2. What is the column letter of the last column with data in on your first worksheet?
3. Where is your command button- on the worksheet, or is it on a userform?
4. What is your command button called (it'll be something like commandbutton1 or cmdSomething)?
5. What message do you want displaying after 259 clicks?
Mudface is offline   Reply With Quote
Old Mar 8th, 2002, 12:36 PM   #5
Guest
 
Posts: n/a
Default

Here is the whole thing, it uses A5000 to hold the counter and saves and closes Excel, if you wanted to just close the workbook then change "Quit" to "Close" in the code.

Sub Bye()
Range("A5000").Value = Range("A5000").Value + 1
If Range("A5000").Value = 259 Then
Range("A5000").Value = 0
str1 = "Your message goes here....."
i = MsgBox(str1, vbInformation + vbOKOnly, "Exiting Now")
End If
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.Quit
Application.DisplayAlerts = True
End Sub

Add the above then add the Button and attach the macro to the button.

Good Luck, Rick E.
  Reply With Quote
Old Mar 8th, 2002, 12:52 PM   #6
Sami
Board Regular
 
Join Date: Mar 2002
Posts: 122
Default

arash shut up lol
Sami is offline   Reply With Quote
Old Mar 8th, 2002, 12:54 PM   #7
Arash_The_A_Level_Student
New Member
 
Join Date: Feb 2002
Posts: 38
Default

Hi, thanks dude that works great only one little problem It doesn't save! but thanks atleast I'm getting somewhere, I don't want it to save the changes of the template I want it to save as a seperate workbook, sorry for not being precise enough
Arash_The_A_Level_Student is offline   Reply With Quote
Old Mar 8th, 2002, 01:15 PM   #8
Arash_The_A_Level_Student
New Member
 
Join Date: Feb 2002
Posts: 38
Default

sami kiss ***
Arash_The_A_Level_Student is offline   Reply With Quote
Old Mar 8th, 2002, 01:33 PM   #9
Guest
 
Posts: n/a
Default

Arash,

I was an A-level student a few years ago and I thought the point was to LEARN new things and then pass the exam/coursework. The reason you're getting negative responses is because you seem to want people to do you work for you without you attempting to do something for yourself i.e. even attempting a little bit of code and then asking for help when it doesn't work. There are many people here who will happily provide code and you'll earn yourself maybe a C grade - attempt something, ask questions, understand an you'll be an A grade. If you want a decent uni place/job/both then believe me, you need to try stuff yourself.

Regards,
Dan,

Ex A-level student.
  Reply With Quote
Old Mar 8th, 2002, 01:45 PM   #10
dk
MrExcel MVP
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
Default

By the way, the previous post was written by me. I neglected to enter my username/password. I am also ashamed that it's 8:45pm on a Friday night and I'm answering questions on an Excel help site! However, I'm waiting for a phone call from a 23 year old north Londoner who seems unattainable but she'll be mine - if only through my Excel knowledge! By the way, I'm sat here with my 6th (and counting) Stella of the evening,

Laters people,
Dan.
dk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:37 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes