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 Apr 25th, 2002, 02:12 PM   #1
bartlett
 
Join Date: Apr 2002
Posts: 52
Default

is there any way in my macro to add one to a number. What i want to do is create my own invoice numbers. So when I get done with an invoice I can start a new invoice with a new invoice number automatically.
bartlett is offline   Reply With Quote
Old Apr 25th, 2002, 02:29 PM   #2
bergy
Board Regular
 
Join Date: Apr 2002
Posts: 112
Default

Have you considered using a workbook as a log? Each column could be a field from the invoice, including the invoice number. When you created a new invoice, the macro would go down the invoice column and then find the last invoice number. I don't think that would be too difficult....
bergy is offline   Reply With Quote
Old Apr 25th, 2002, 02:43 PM   #3
bartlett
 
Join Date: Apr 2002
Posts: 52
Default

how?
bartlett is offline   Reply With Quote
Old Apr 25th, 2002, 03:34 PM   #4
bergy
Board Regular
 
Join Date: Apr 2002
Posts: 112
Default

When you ask "how?", do you mean how do you have the macro find the next number? If so, you could have the macro start at the top of the invoice column and then do a end(xlDown) to find the end of the data in that column. The number in that cell would be the last invoice (assuming the page is sorted by invoice number) and your next invoice would be that number + 1. Do you have a worksheet as a log?
bergy is offline   Reply With Quote
Old Apr 25th, 2002, 03:43 PM   #5
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

If A1 has your number and you want B1 to equal A1 + 1 use the following code
Code:
[b1] = [a1] + 1
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old Apr 25th, 2002, 03:44 PM   #6
Jack in the UK
Board Regular
 
Join Date: Feb 2002
Posts: 3,064
Default

Im a finance guy on sale ledger.. this is my ground and no one has really come up with a workable solution if the company dont run finance packsge thats doing this so excel to the rescue..
YES it can be done but its a build brick by brick task

do you have the invoice template.

do you have table of addresses to ie debtor address list so we can use this to produce the inmvoice.

do you have stock or servoice sheet so we can charge the customer.

these are the 3 MUST then we can move on or its pointless.


__________________
Free Excel based Web Toolbar available here.

Jack in the UK
J & R Excel Solutions
"making Excel work for you"
Jack in the UK is offline   Reply With Quote
Old Apr 25th, 2002, 03:44 PM   #7
bartlett
 
Join Date: Apr 2002
Posts: 52
Default

I am using a basic worksheet. I should say we are doing invoices one at a time where we enter the info, print, hit a macro to log into another worksheet, then enter the info again on the invoice. Cumbersome, yes, but we dont do many this way. And since we dont do many we want to be able to press the macro button and have the new invoice number set so when we come back to it we don't have to look up any old invoices. I apologize for the confusion-suggestions? thanks
bartlett is offline   Reply With Quote
Old Apr 25th, 2002, 03:50 PM   #8
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

Assume that your data is logged in sheet2 and the existing invoice numbers are in column A.

When the invoice is loaded and the form is reset, would setting the invoice cell to
=MAX(Sheet2!A:A)+1
work for you?

If it is in VBA, you can do the same thing very easily.

Sub test()
Dim InvoiceNumber As Long

InvoiceNumber = WorksheetFunction.Max(Sheets("Sheet2").Range("A:A")) + 1
MsgBox InvoiceNumber
End Sub

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old Apr 25th, 2002, 03:51 PM   #9
bartlett
 
Join Date: Apr 2002
Posts: 52
Default

just thought of something-is there a way to set up a macro or formula to generate a number? sequentially?
just a thought.
bartlett is offline   Reply With Quote
Old Apr 25th, 2002, 03:57 PM   #10
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Not sure I'm following, but if you want a separate worksheet for every invoice
Code:
Sub Invoicer()    
n = [a1].Value + 1
ActiveSheet.Copy after:=ActiveSheet
ActiveSheet.Name = "Invoice_" & n
[a1] = n
End Sub
Where cell a1 houses your invoice number. The only reason for copying the active sheet is to grab the formatting you can clear the contents quickly via code, e.g.,

Code:
[a7].clearcontents
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO 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 12:27 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