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 7th, 2002, 07:41 PM   #1
Morrissey
Board Regular
 
Join Date: Mar 2002
Posts: 85
Default

Ok I Have Made This Code That Sends Data From My Invoice System For My Freight forwarding Company To A Sort Of Database Here Is The Code:

Sub Send_To_Database()
Application.ScreenUpdating = False
Sheets("Automated Invoice").[G11].Copy
Sheets("Database").Select
[A65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[B11].Copy
Sheets("Database").Select
[B65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[E13].Copy
Sheets("Database").Select
[C65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[B13].Copy
Sheets("Database").Select
[D65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[B15].Copy
Sheets("Database").Select
[E65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[B16].Copy
Sheets("Database").Select
[F65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G18].Copy
Sheets("Database").Select
[G65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G19].Copy
Sheets("Database").Select
[H65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G20].Copy
Sheets("Database").Select
[I65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G21].Copy
Sheets("Database").Select
[J65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G22].Copy
Sheets("Database").Select
[K65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True

Application.ScreenUpdating = False
Sheets("Automated Invoice").[G49].Copy
Sheets("Database").Select
[L65536].End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
Application.CutCopyMode = False
Sheets("Automated Invoice").Select
Application.ScreenUpdating = True
End Sub


Ok The Code Works Perfectly However Because The Data Is On My Invoice Tempalte Is Formatted It Transfers Thr Formattted Text On To The Database I Don't Want This To Happen I Would Like It Formatted As 'Arial 10' Does Anyone Know How To Do This If So Help Is Needed Thanks,


(PS that template thing doesn't work for me with the MS add ons as there is various complcations on my invoice system that prevents that so I need to do it this way so please don't suggesst top do that I know this is the way I have to do it!)

Your Pal Mozz
Morrissey is offline   Reply With Quote
Old Apr 7th, 2002, 08:03 PM   #2
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

Not sure but try adding
With ActiveCell.Characters(Start:=1, Length:=14).Font
.Name = "Arial"
.Size = 10

End With
into your code
brettvba is offline   Reply With Quote
Old Apr 7th, 2002, 08:16 PM   #3
Dave Hawley
Banned
 
Join Date: Feb 2002
Posts: 1,582
Default

Hi Moz

I hope you don't mind me saying, but you are going about this the long way. Try some code like this:

Code:
Sub Send_To_Database()
Dim i As Integer
Dim strRange As Range

For i = 1 To 12
    strRange = Choose(i, "G11", "B11", "E13", "B13", "B15", "B16", _
                         "G18", "G19", "G20", "G21", "G22", "G49")
                         
    Sheets("Automated Invoice").Range(strRange).Copy Destination:= _
    Sheets("Database").Range("A65536").End(xlUp).Offset(1, 0)
    With Sheets("Database").Range("A65536").End(xlUp).Font
        .Name = "Arial"
        .Size = 10
    End With
    
Next i

End Sub
Much easier to read and De-bug.


Dave Hawley is offline   Reply With Quote
Old Apr 8th, 2002, 05:24 AM   #4
Morrissey
Board Regular
 
Join Date: Mar 2002
Posts: 85
Default

Thank You Very Much For Your Help
Morrissey is offline   Reply With Quote
Old Apr 8th, 2002, 05:43 AM   #5
Morrissey
Board Regular
 
Join Date: Mar 2002
Posts: 85
Default

Hi David One Little Problem With Your Code Don't Worry I Thought I Was Going The Long Way Anyway But I Have Replaced Your Code With Mine And When I try To Execute The Code A Debug Error Message Comes Up Saying


"Object Variable With Block Variable Not Set"

and when I go to debug this is what is highlighted


strRange = Choose(i, "G11", "B11", "E13", "B13", "B15", "B16", _
"G18", "G19", "G20", "G21", "G22", "G49")

just a little more help please! we are nearly there!!!
Morrissey is offline   Reply With Quote
Old Apr 8th, 2002, 08:30 AM   #6
Morrissey
Board Regular
 
Join Date: Mar 2002
Posts: 85
Default

someone please
Morrissey is offline   Reply With Quote
Old Apr 8th, 2002, 11:46 AM   #7
Morrissey
Board Regular
 
Join Date: Mar 2002
Posts: 85
Default

come on someone
Morrissey is offline   Reply With Quote
Old Apr 8th, 2002, 12:56 PM   #8
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-04-08 10:46, Morrissey wrote:
come on someone
Hi,

I don't see the problem off hand. Make sure you have the "end with" in the statement at the end.

Please copy and paste your code exactly as you have it. We need to compare if there are any typos or anything missing from Dave's code and what you have.

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old Apr 8th, 2002, 01:12 PM   #9
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

There is a type mismatch in the code because strRange is dimensioned as a Range, but then it is used as a String.

Change

Dim strRange As Range
to
Dim strRange As String

and it should work for you.

Bye,
Jay
Jay Petrulis 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 04:10 PM.


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