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 19th, 2002, 07:50 AM   #1
rkohlbeck
New Member
 
Join Date: Apr 2002
Location: Ryan Kohlbeck
Posts: 4
Default

Hello, I'm new to excel so bear with me.

I have a list like this:

John Doe
1234 Happy St
Anywhere, NC 11111
123-123-1234

Happy Guy
4321 Sad St
PO Box 12
Nowhere, WI 55555
321-321-4321

They are all in column A (2000 rows). There is a blank row before each new info section. So what I need is this list in columns.
Column A = Name
Column B = Street Address
Column C = Mailing Address

And so on. I've tried a few things, but I just can't get it all the way.

Thanks!
rkohlbeck is offline   Reply With Quote
Old Apr 19th, 2002, 08:02 AM   #2
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

Is this the dreaded ACT??

Have a look at the following post and see if it's any use...

http://www.mrexcel.com/board/viewtop...c=1313&forum=2
AJ is offline   Reply With Quote
Old Apr 19th, 2002, 08:44 AM   #3
rkohlbeck
New Member
 
Join Date: Apr 2002
Location: Ryan Kohlbeck
Posts: 4
Default

Well, yes, It is exactly what I need. But it didn't work.

I ran it and it started pasting all the contents in Row 1. One right after another. I actually would like each Mailing record on a separate row. After a few seconds I received a run-time error '1004' something about an Application Defined or Object oriented error.

After going to the debugger it was stuck on this line:

ActiveCell.Offset(0, myIncrement).Select

I appreciate any further help.
rkohlbeck is offline   Reply With Quote
Old Apr 19th, 2002, 09:22 AM   #4
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

Sorry about that. I'm sure that code did use to work!
Anyway, I've had another shot. Try this way instead (even commented my code for once - a real novelty!)

Sub Secondattempt()

Dim LastRow As Integer
Dim PasteRow As Integer

' Set PasteRow
PasteRow = 1
' Data starts in Cell A1
Range("A1").Select
' Start Loop
Do While ActiveCell.Value <> Empty
' Select all cells in current address
Range(Selection, Selection.End(xlDown)).Select
' Determine what last row is (we need this later)
LastRow = Selection.End(xlDown).Row
' Copy the current selection
Selection.Copy
' Select where to paste
Range("B" & PasteRow).Select
' Paste
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
' Delete the first address
Range("A1:A" & LastRow + 1).Select
Selection.Delete Shift:=xlUp
' Increase Pasterow by 1
PasteRow = PasteRow + 1
' Start again
Range("A1").Select
Loop
' Delete Column A because it's now empty
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft

End Sub
AJ is offline   Reply With Quote
Old Apr 19th, 2002, 09:36 AM   #5
rkohlbeck
New Member
 
Join Date: Apr 2002
Location: Ryan Kohlbeck
Posts: 4
Default

Thanks AJ for your all your help, but it still doesn't work.

I get a runtime error:

The information cannot be pasted because the copy area and the paste area are not the same size and shape. Try one of the following:
+ Click a single cell, then paste
+ select a rectangle that's the same size and shape, then paste.

When I click the Debug button, It highlights this line:

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

You are a trooper! I have no clue what is going on.

rkohlbeck is offline   Reply With Quote
Old Apr 19th, 2002, 09:38 AM   #6
Henry
Board Regular
 
Join Date: Mar 2002
Location: Mike T.
Posts: 180
Default

Ryan: Did you read my suggestion.

Mike (210) 498-1459
Henry is offline   Reply With Quote
Old Apr 19th, 2002, 09:43 AM   #7
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

Hello again,

I think the problem might me that the blank lines in between each address are not utterly empty.
Can you check one of the blank cells and see whether there's actually a space in it or something like that.
If there is then the
Range(Selection, Selection.End(xlDown)).Select
would actually select pretty much the whole damned column and that would be more than 256 items, which would not fit into the 256 columns we have in Excel and give you the error when we try to PasteSpecial Transpose.

I'll assume that this is the problem for the moment and try and adjust the code accordingly.

P.S. Feel free to email me the file. It might help me.
AJ is offline   Reply With Quote
Old Apr 19th, 2002, 09:51 AM   #8
AJ
Board Regular
 
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
Default

If the "Blank" rows do in fact contain spaces, then try this...

Sub Thirdattempt()

Dim LastRow As Integer
Dim PasteRow As Integer

' Set PasteRow
PasteRow = 1
' Data starts in Cell A1
Range("A1").Select
' Start Loop
Do While ActiveCell.Value <> Empty
' Go down current address and find out where it ends (looking for a cell with a space)
Do While ActiveCell.Value <> " "
ActiveCell.Offset(1, 0).Select
LastRow = ActiveCell.Row
Loop
' N.B. LastRow is now actually the blank row
' Copy the current selection
Range("A1:A" & LastRow - 1).Select
Selection.Copy
' Select where to paste
Range("B" & PasteRow).Select
' Paste
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
' Delete the first address
Range("A1:A" & LastRow).Select
Selection.Delete Shift:=xlUp
' Increase Pasterow by 1
PasteRow = PasteRow + 1
' Start again
Range("A1").Select
Loop
' Delete Column A because it's now empty
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft

End Sub

Any improvement??

Rgds
AJ
AJ is offline   Reply With Quote
Old Apr 19th, 2002, 11:16 AM   #9
rkohlbeck
New Member
 
Join Date: Apr 2002
Location: Ryan Kohlbeck
Posts: 4
Default

Well, we got by that error. It keeps running down until a runtime errors out with a overflow.
my list is about 1800 lines. it ran straight down to 32768 before the oveflow came.

When I hit Debug it stopped here:

LastRow = ActiveCell.Row

Sorry about this. I hate to use anyone's time. Henry suggested an Add-in I might try, "PuP". I'll keep looking if you want to keep trying, but I'll understand if we can't get this.

Thanks All
rkohlbeck is offline   Reply With Quote
Old Apr 19th, 2002, 12:32 PM   #10
Henry
Board Regular
 
Join Date: Mar 2002
Location: Mike T.
Posts: 180
Default

PuP will fix it--guaranteed. I think I paid $60 or so.

Besides that Transpose thing (go to Range inl the menu), it's got a bunch of neat things I used all the time. I'm surprised MS hasn't jumped on their band wagon and updated there version. Again, you can use if for a while (free trial period). If you get stuck (almost impossible) loading the Add-In, let me know. You'll flip when you see this thing in action. I think it was made by that John Walkenbach guy or something like that. Let me know what you do--just curious.

Henry
Henry 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:50 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