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 May 23rd, 2002, 02:39 AM   #1
Juggernaut
New Member
 
Join Date: May 2002
Posts: 6
Default

Right, this is my problem:
  • I need to scan through a spreadsheet, row by row.
  • If cell F(x) is blank, then it will move on to check the next row.
  • If cell Fx was NOT blank, and cell Ex IS blank, it will copy that line (Cells Ax to Hx)
  • It then needs to open the corresponding sheet in another workbook and paste that data into the first available (blank) line.
  • It then returns to check the next line until the first 100 lines of the original sheet have all been checked and copied if appropriate.
  • As neither of those 2 sheets can contain macros, this needs to be run from a 3rd workbook, the sole purpose of which is to run this macro.

At the moment I'm getting a variety of errors generally when it comes to the pasting stage, and can't get my head around the problem.

Any suggestions?
For the record, am using Excel 97 SR2 (can't upgrade - work system) and this is my code so far:

********************************************

Private Sub CommandButton1_Click()

'Prepare Excel:
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False

'Open fault sheet
Workbooks.Open FileName:="W:Monthly Fault SheetFault Sheet (MAY onwards) 2002.xls"
Workbooks.Open FileName:="W:Monthly Fault SheetDaily Fault Handoff.xls"


' ***** GENERAL NETWORK *****

Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A4:H100").ClearContents

For GenNet = 4 To 100
If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 6) = "" Then GoTo GenNetSkip
If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 5) = "" Then Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Range.Cells(GenNet, 1).Cells(GenNet, 8).Copy


For GenNet2 = 4 To 100
If Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet2, 1) = "" Then GoTo GenNetPaster
Next GenNet2
GoTo GenNetSkip

GenNetPaster:
Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A" & GenNet2, "H" & GenNet2).Select
Selection.PasteSpecial (x1PasteAll)


GenNetSkip:
Next GenNet

'Re-set Excel
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub



[ This Message was edited by: Juggernaut on 2002-05-23 02:00 ]
Juggernaut is offline   Reply With Quote
Old May 23rd, 2002, 03:54 AM   #2
Juggernaut
New Member
 
Join Date: May 2002
Posts: 6
Default

Ok, I've got a little further now - I can see where it's going wrong. Basically it's not getting the information into the clipboard properly, so when it comes to paste it has nothing to paste.

If you already have something in the clipboard, it pastes that.

The code is now:

*********************************************

Private Sub CommandButton1_Click()

'Prepare Excel:
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False

'Open fault sheet
Workbooks.Open FileName:="W:Monthly Fault SheetFault Sheet (MAY onwards) 2002.xls"
Workbooks.Open FileName:="W:Monthly Fault SheetDaily Fault Handoff.xls"


' ***** GENERAL NETWORK *****

Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Range("A4:H100").ClearContents

For GenNet = 4 To 100
Workbooks("Fault Sheet (MAY onwards) 2002.xls").Activate
If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 6) = "" Then GoTo GenNetSkip
If Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Cells(GenNet, 5) = "" Then Workbooks("Fault Sheet (MAY onwards) 2002.xls").Worksheets("General network ").Range("A" & GenNet, "H" & GenNet).Select
Selection.Copy

For GenNet2 = 4 To 100
If Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet2, 1) = "" Then GoTo GenNetPaster
Next GenNet2
GoTo GenNetSkip

GenNetPaster:
Workbooks("Daily Fault Handoff.xls").Activate
Workbooks("Daily Fault Handoff.xls").Worksheets("General Network").Cells(GenNet, 2).Select
Selection.PasteSpecial (x1PasteAll)


GenNetSkip:
Next GenNet

Workbooks("Daily Fault Handoff.xls").Activate

'Re-set Excel
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

*********************************************

Where am I going wrong?!
Juggernaut 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 05:52 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