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 13th, 2002, 01:02 PM   #1
PDuPre'
Board Regular
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

Hello, appreciate any help,

I have an error log that prints out two rows of data seperated by a blank row for each error. The error log prints out each month. There may be several hundred errors, but all but a few have a value of zero and are irrelevant.

The first row of each error has 7 cells of data. The second row has 8 cells of data. The 6th cell (column) on the second row is the value. If it does not equal zero then I'd like to see that error.

Looking for some VBA code to take each valid error and write it to another worksheet. Ideally I will initiate the macro via a button or other trigger and have the valid errors print out on the page below. Will repeat periodically each month. No need to keep a record of prior valid errors.

I have a macro that can open the comma delimited text file, format it, copy it and apply a formula to identify the columns with the valid errors, but I don't know how to write the 2 rows of data to the second worksheet.

Thank for any help,

Philip
PDuPre' is offline   Reply With Quote
Old May 13th, 2002, 01:13 PM   #2
Nimrod
MrExcel MVP
 
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
Default

If row 8 ( for example) has errorCode>0 do you want both Row 7 and Row 8 copied to second sheet or just Row 8 ?
__________________

<MARQUEE>...........Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic...............The easiest thing to find is fault, don't be easy !.. --Anonymous--...</marquee>
Nimrod is offline   Reply With Quote
Old May 13th, 2002, 01:25 PM   #3
PDuPre'
Board Regular
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

Quote:
On 2002-05-13 12:13, Nimrod wrote:
If row 8 ( for example) has errorCode>0 do you want both Row 7 and Row 8 copied to second sheet or just Row 8 ?
I would want both row 7 and row 8 ideally.

Philip
PDuPre' is offline   Reply With Quote
Old May 13th, 2002, 01:30 PM   #4
bergy
Board Regular
 
Join Date: Apr 2002
Posts: 112
Default

[/quote]
I would want both row 7 and row 8 ideally.

Philip
[/quote]

The code below only takes the 2 rows, but only the first 8 cells. It does not copy the entire row.

Sub test()

ErrorLog = ActiveSheet.Name
LastRow = Cells(65536, 1).End(xlUp).Row
Col_A = 1
Col_F = 6
Col_H = 8
RowNum = 1 'Adjust for you start row

ErrorLog = ActiveSheet.Name
While RowNum < LastRow
If Cells(RowNum + 1, Col_F).Value <> 0 Then
Range(Cells(RowNum, Col_A), Cells(RowNum + 1, Col_H)).Select
Selection.Copy
Sheets("Sheet2").Select
If (Cells(1, 1).Value) = "" Then
Cells(1, 1).Select
Else
Cells(65536, 1).End(xlUp).Offset(2, 0).Select
End If
ActiveSheet.Paste
Sheets(ErrorLog).Select
End If
RowNum = RowNum + 3
Wend
End Sub


Hope it works!
bergy is offline   Reply With Quote
Old May 13th, 2002, 01:31 PM   #5
bergy
Board Regular
 
Join Date: Apr 2002
Posts: 112
Default

Oops! Forgot to mention you would need to mofify the sheet names.
bergy is offline   Reply With Quote
Old May 13th, 2002, 01:31 PM   #6
Nimrod
MrExcel MVP
 
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
Default

One last question:
If Row 8 Col 6 has your error value what does Row7 col6 have ? In other words is it a number or text ? It would make the solution easier if C7 and C8 had different data types.
__________________

<MARQUEE>...........Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic...............The easiest thing to find is fault, don't be easy !.. --Anonymous--...</marquee>
Nimrod is offline   Reply With Quote
Old May 13th, 2002, 01:37 PM   #7
PDuPre'
Board Regular
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

Quote:
On 2002-05-13 12:31, Nimrod wrote:
One last question:
If Row 8 Col 6 has your error value what does Row7 col6 have ? In other words is it a number or text ? It would make the solution easier if C7 and C8 had different data types.
Row 7 column 6 is text. It contains the word "In" every time.

Philip

[ This Message was edited by: PDuPre' on 2002-05-13 13:11 ]
PDuPre' is offline   Reply With Quote
Old May 13th, 2002, 01:42 PM   #8
PDuPre'
Board Regular
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

Quote:
On 2002-05-13 12:30, bergy wrote:
Hope it works!
I'll try it. Thanks for the quick response. MS-Word locked up half my machine, so I'll reboot and give it a try.
Nimrod, if you have a different way to do this, I'd love to see it. Trying to learn as much as I can.

Thanks!

Philip
PDuPre' is offline   Reply With Quote
Old May 13th, 2002, 02:09 PM   #9
PDuPre'
Board Regular
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

It works. Took me a bit to get it setup, but it copied over everything I wanted and nothing I didn't.

Thanks!

Philip
PDuPre' is offline   Reply With Quote
Old May 13th, 2002, 02:15 PM   #10
Nimrod
MrExcel MVP
 
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
Default

Oh well to late ... well here it is anyway.
Code:
Sub CopyErrorLog()
    SourceSheet = "ErrorLog"
    TargetSheet = "ErrorSummary"
    TargRow = 1
    EvalCol = 6

For RwCnt = 2 To 65536 Step 2
    If Val(Sheets(SourceSheet).Cells(RwCnt, EvalCol).Value) > 0 Then ' copy and paste
        Worksheets(SourceSheet).Range(RwCnt - 1 & ":" & RwCnt).Copy
        Sheets("ErrorSummary").Range(TargRow & ":" & TargRow + 1).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
        TargRow = TargRow + 2
    End If
    If Len(Trim(Sheets(SourceSheet).Cells(RwCnt, 1))) = 0 Then Exit Sub
Next
End Sub
Nimrod 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:42 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