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 8th, 2002, 02:19 PM   #1
Zac
Board Regular
 
Join Date: Feb 2002
Location: Mike
Posts: 796
Default

Nate,
I tried your suggestion for the following:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/8/2002 by Mike Zaccardo
'
Dim cell As Range

'where I replaced .Range("M2:M" & lastrow) = "If(RC[-2]<0,RC*-1,RC)" with

For Each cell In Range("m1:m" & lastrow)
If cell.Offset(, -2).Value < 0 And cell.Value > 0 _
Then cell = -cell.Value
Next cell
End Sub

On the coding above I'm getting a DEBUG msg on "For Each cell....."

Trying to change the value in a cell to a negative number if the total sales 2 cells to the left is negative.
Zac is offline   Reply With Quote
Old May 8th, 2002, 02:42 PM   #2
James
Board Regular
 
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
Default

Add the End If and see if it works:

Then cell = -cell.Value
next cell
>>End IF<<
End Sub

James
James is offline   Reply With Quote
Old May 8th, 2002, 05:11 PM   #3
Amds
 
Join Date: Mar 2002
Posts: 22
Default

Your macro doesn't include any value for "Lastrow".
Amds is offline   Reply With Quote
Old May 8th, 2002, 05:47 PM   #4
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Hi Zac, in your original post, you had:

Code:
Dim lastrow As Long 
Dim UsedRng As Range, UsedCell As Range 
lastrow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Did you remove these statements, if so, we'll need to add them back, let XL know when the last cell in the range to be tested is.

No matter, allow me to compile:

Code:
Dim lastrow As Long, cell As Range
Dim UsedRng As Range, UsedCell As Range
'other code
lastrow = .Cells.SpecialCells(xlCellTypeLastCell).Row
For Each cell In Range("m1:m" & lastrow)
If cell.Offset(, -2).Value < 0 And cell.Value > 0 _
Then cell = -cell.Value
Next cell
'other code
Incidentally, as a bean counter, I'm curious, if you get a return, the quantity is positive, wouldn't you want the $ amount negative? Thus telling you have a credit (versus debit with positive numbers) to your cash account?

No matter. Your other code looked to be in good shape (at the time...). Hope this helps.

_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-08 16:56 ]
NateO is offline   Reply With Quote
Old May 9th, 2002, 05:53 AM   #5
Zac
Board Regular
 
Join Date: Feb 2002
Location: Mike
Posts: 796
Default

NateO,

All our data is extracted from our MRP module.
The columns run from a:aa, and the rows vary from 200+.
The bookkeeper then spends about 3-5 hours
deleting and adding what is and isn't needed.
There is a column of "Total Sales" for line items, and a few turn up negative. There is
a "Qty Shipped" column, but theses numbers get brought over as "positive".
Why I don't know.

Being self taught with XL, I always try to learn something new every day. So I decided to try and learn how to record macro's, with the intent of automating what they need done in Accounting at time of extraction.

Needless to say the first month end closing ran great. But the previous recording left me with a couple of minor problems, which caused some lines not to be used correctly.
One of them was the use of the Data Filter, and the one mentioned above (changing the Qty Shipped line that's associated with a Negative Total Sales number.

I hope your idea does the trick.

The Data Filter is another headache.
I use the D/F to show a salesmans Commission Code (ie: 026). I'm trying to figure out
how to go from B1 to the next line down.
The visible lines vary each month (39:80)
(51:75), etc . When I use the down arrow in my recording, it initially set up a scenario of goto (39,0) as example. If my data runs from (30:50), it jumps over (30:38).

Sorry to ramble on. That's it in a nutshell.

Thanks for your help, I hope the last suggestion works (using DOWN instead of using the down arrow).

Thanks,
Zac

Zac is offline   Reply With Quote
Old May 9th, 2002, 10:34 AM   #6
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Not necessarily following, but I think the code above will take care of column M's data. with respect to:

Quote:
I'm trying to figure out
how to go from B1 to the next line down
Try:
Code:
[b1].Offset(1).Select 'change select to what you want it to do (e.g., copy)
__________________
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 04:24 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