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 15th, 2002, 09:00 AM   #1
johnandbeth
Board Regular
 
Join Date: Apr 2002
Posts: 164
Default

I tried the solution in the posting "VB Code to move data from one sheet to another" posted 4-16-02.
It works except I need it to look for a date range. Any suggestions?

Instead of the word "complete", I tried to enter "01/**/**" and I tried "01/??/??" hoping one of those wildcards would work, but it didn't.

I'm trying to copy data from "2002 Data" worksheet to the "January" worksheet.
johnandbeth is offline   Reply With Quote
Old May 15th, 2002, 09:21 AM   #2
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

I've never used the particular function in the post from 4/16, but I believe you can use the left function in some way.

Left(cell,3) = "01/"

I'd have done the whole thing differently, so this may not apply...

K
kkknie is offline   Reply With Quote
Old May 15th, 2002, 09:30 AM   #3
johnandbeth
Board Regular
 
Join Date: Apr 2002
Posts: 164
Default

So, instead of typing ("NOT(ISERROR(SEARCH(""COMPLETE""," & usedcell.Address & ",1)))") as it shows in the 4/16/02 post you would suggest that I type ("NOT(ISERROR(SEARCH(""Left(cell,3) = "01/"
""," & usedcell.Address & ",1)))") ?

I'm pretty new to VB, so I'm sorry if I seem like an idiot.

If this isn't what you mean, can you explain it simply to me?

Also, you said you would have done it completely differently. I'm not locked to this way of doing it, so if you have any other way of reaching the same solution, I'd love to hear it.

And thank you for your help!!
johnandbeth is offline   Reply With Quote
Old May 15th, 2002, 09:37 AM   #4
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Maybe...?

I am really not familliar with the method used, so I cannot tell.

I would have done it using a simple loop through the row using the cells array. Post some more information on your exact problem and I will try to work it out over lunch.

K
kkknie is offline   Reply With Quote
Old May 15th, 2002, 09:42 AM   #5
johnandbeth
Board Regular
 
Join Date: Apr 2002
Posts: 164
Default

Thank you for the wonderful offer.

I have a workbook that has 13 worksheets. The first one is the data entry sheet and is titled "2002 Data", then there are 12 worksheets, each with a month title (January, February, etc).

What I want is a macro/vbcode that will copy the data in the "2002 Data" worksheet to each month, to the last row on each monthly worksheet. So if the info came in about a problem in January (even though the call came in April), it would copy that January problem to the January worksheet.
Does this make sense?

The user is very scared of the computer, so the more I can automate the better.
johnandbeth is offline   Reply With Quote
Old May 15th, 2002, 10:10 AM   #6
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Questions:

1. Does any new data get entered on the monthly sheets or are they a direct copy of the yearly one?

2. Do you want the monhtly's sorted in any way?

3. About how many rows would be on the yearly sheet by the end of the year?

K
kkknie is offline   Reply With Quote
Old May 15th, 2002, 10:14 AM   #7
johnandbeth
Board Regular
 
Join Date: Apr 2002
Posts: 164
Default

Answers:

1. No, just entered on the yearly sheet. (Does any new data get entered on the monthly sheets or are they a direct copy of the yearly one?)

2. Yes, by the "u/w" field - this is the name of the person entering the info.
(Do you want the monhtly's sorted in any way?)

3. Probably 300-500 rows.
(About how many rows would be on the yearly sheet by the end of the year?)
johnandbeth is offline   Reply With Quote
Old May 15th, 2002, 10:38 AM   #8
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

I like to call this the "Brute Force" method...

Basically, I delete all of the monthly sheets, copy the main sheet 12 times and rename for months, sift through the month sheets and delete anything not that month.

I ran it on a P3 500 MHz (256MB RAM) machine with 600 rows and it took 19 seconds to complete. I am working on speeding it up, but may not be able to finish (1pm meeting).

It has the following assumptions:

First sheet name is MAIN (yearly data)
Data starts in row 2 (headers in row 1)
Date is in first column
Workbook always has 13 sheets

Questions? I'll be gone from 1pm-3pm EDT.

Sub Move_Months()

Dim i As Long
Dim j As Long

Application.ScreenUpdating = False
Application.DisplayAlerts = False
For i = 2 To 13
Sheets(2).Delete
Next

Sheets("MAIN").Select
Sheets("MAIN").Copy After:=Sheets(1)
Sheets(2).Name = "JAN"
Sheets(2).Copy After:=Sheets(2)
Sheets(3).Name = "FEB"
Sheets(3).Copy After:=Sheets(3)
Sheets(4).Name = "MAR"
Sheets(4).Copy After:=Sheets(4)
Sheets(5).Name = "APR"
Sheets(5).Copy After:=Sheets(5)
Sheets(6).Name = "MAY"
Sheets(6).Copy After:=Sheets(6)
Sheets(7).Name = "JUN"
Sheets(7).Copy After:=Sheets(7)
Sheets(8).Name = "JUL"
Sheets(8).Copy After:=Sheets(8)
Sheets(9).Name = "AUG"
Sheets(9).Copy After:=Sheets(9)
Sheets(10).Name = "SEP"
Sheets(10).Copy After:=Sheets(10)
Sheets(11).Name = "OCT"
Sheets(11).Copy After:=Sheets(11)
Sheets(12).Name = "NOV"
Sheets(12).Copy After:=Sheets(12)
Sheets(13).Name = "DEC"

For i = 2 To 13
Sheets(i).Select
Columns("A:K").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A1").Select
Next

For i = 2 To 13
Sheets(i).Select
iFound = 0
For j = 2 To 65000
If Cells(j, 1).Value = "" Then Exit For
If Month(Cells(j, 1)) <> i - 1 Then
Cells(j, 1).Select
Selection.EntireRow.Delete
j = j - 1
End If
Next
Next i


Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

P.S. Try it out on a temporary worksheet since it does do a lot of deletions...

[ This Message was edited by: kkknie on 2002-05-15 09:40 ]
kkknie is offline   Reply With Quote
Old May 15th, 2002, 01:19 PM   #9
johnandbeth
Board Regular
 
Join Date: Apr 2002
Posts: 164
Default

It didn't really work for me. I know there are more than 4 January entries, but it only copied over 4 total entries to the January worksheet, and one of those was a March entry.
johnandbeth 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:09 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