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 25th, 2002, 07:43 PM   #1
jbyrne
Board Regular
 
Join Date: Feb 2002
Posts: 165
Default

OK, I was at work and typing fast so I don’t think I came across clear at all. I will now try to explain what I am trying to accomplish now that I am not doing more than 15 things at a time!!

I have the following worksheet Columns A thru M
A NAME
B STREET ADDRESS
C BLANK (ADDRESS2)
D CITY
E STATE
F ZIP CODE WITH 4 DIGIT EXTENTION
G A “FROM DATE” WHEN THE ADDRESS WAS REPORTED
H A “TO DATE” WHEN THE ADDRESS WAS REPORTED
I SOCIAL SECURITY NUMBER
J NAME OF EMPLOYER1
K DATE EMPLOYER 1 WAS REPORTED
L NAME OF EMPLOYER 2
M DATE EMPLOYER 2 WAS REPORTED

The problem I am having is that some people have more addresses than others. What I need to do the following. Let’s say for instance we have this….

John Smith 123 5th Street Tallahassee Fl 32301-5837 Oct-98 Nov-00 123-45-6789 Tallahassee Diner 1-Aug AJ Auto Parts Feb-00

John Smith may have 4 different listings taking up row 1-4. What I want to do is put all of John Smiths info on 1 row. (Putting the 2nd listing for John Smith and all his info starting at N1 thru Z1 and so on…. Hope this is more clear to everyone. Any help would be appreciated.

jbyrne is offline   Reply With Quote
Old Apr 25th, 2002, 07:53 PM   #2
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

Did the routines I posted fail? It seems to me that changing the range which is being copied from
,4).copy
to
,13).copy

would work (sorry, I can't recall the code off hand)

Let us know what is wrong with it, or what else you need.

Additionally, please don't start a new thread on the same topic, if possible. This should've been added to your prior thread so that there is no loss of continuity, and clowns like me don't have to go find the previous post.

Bye,
Jay
Jay Petrulis is offline   Reply With Quote
Old Apr 25th, 2002, 08:00 PM   #3
jbyrne
Board Regular
 
Join Date: Feb 2002
Posts: 165
Default

Hi Jay,

Sorry about that starting a new thread. I'm new to realitively new to the board but loving all the help I get. I know now thanks to you to continue on the same thread. I copied the code and ran the macro. It seemed to take the first row of each name and than I got an error when it pasted the 4th record.

I believe that was my fault for not explaining exactly what I needed.
jbyrne is offline   Reply With Quote
Old Apr 25th, 2002, 08:11 PM   #4
jbyrne
Board Regular
 
Join Date: Feb 2002
Posts: 165
Default

What I basically want is excel to look at a2 and if a2 is the same name as a1 than move row 2 to N1 TO NZ
than continue downward....
look at a3, if same as a1 then move entire row to end of row 1

look at a4, if different name, look at a5, if same as a4 than cut entire row 5 and paste to end of row 4.

hope this helps
jbyrne is offline   Reply With Quote
Old Apr 25th, 2002, 08:16 PM   #5
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

The routine is working for me, no matter how many records.

What it is doing is getting a list of all the uniques names in column A of the data sheet and copies them to the second sheet. It then goes through the data set 1 by 1 and loads the corresponding values to each row where the names match. Multiple names get sent to the end of the row as requested.

When you say it bombs, what exactly is happening? I do not doubt that you are having a problem, it is just that I cannot replicate it.

Jay
Jay Petrulis is offline   Reply With Quote
Old Apr 25th, 2002, 08:20 PM   #6
jbyrne
Board Regular
 
Join Date: Feb 2002
Posts: 165
Default

Let me try it again, I may be doing something wrong.... I'll try it and get back to you....Thanks
jbyrne is offline   Reply With Quote
Old Apr 25th, 2002, 08:33 PM   #7
jbyrne
Board Regular
 
Join Date: Feb 2002
Posts: 165
Default

I ran the macro again, it inserted 7 names in column G and than received a run bug error #9.

I looked at sheet2 and there was nothing there.

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

Delete the sub and use this one, instead.

---------------
Sub test()
Dim counter As Long, lastrow As Long, x As Long
Dim matchrow As Long, lastcol As Integer

With ActiveSheet
.UsedRange
lastrow = .Cells.SpecialCells(xlCellTypeLastCell).Row
.Columns("N:N").Clear
.Columns("A:A").AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("N1"), Unique:=True
.Range("N1").Delete shift:=xlUp

counter = WorksheetFunction.CountA(.Range("N:N"))
.Range("N1:N" & counter).Copy Sheets("sheet2").Range("A1")
.Range("N1:N" & counter).ClearContents

For x = 2 To lastrow
matchrow = Application.Match(.Cells(x, 1), Sheets("Sheet2").Range("A:A"), 0)
lastcol = Sheets("Sheet2").Cells(matchrow, 256).End(xlToLeft).Column
.Range(.Cells(x, 2), .Cells(x, 13)).Copy Sheets("Sheet2").Cells(matchrow, lastcol + 1)
Next x
End With
MsgBox "Done!"

End Sub
--------------------

Please note that this will *not* duplicate the names, only the extra information. If that is required, it will be an easy fix, but we need to get the main routine running 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 07:16 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