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 Feb 21st, 2002, 07:17 AM   #1
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

All,

I have an ammount of data on a daily basis that is copied from Kea! Connect to an Excel sheet,

when pasted it looks like:

PLC_001A 1000
Call Date 19-Feb 2
Member no 123456-1234554321
CONTACT Mr John Smith
POST CODE XX77 7XX
Reg no X123 ABC
Make MN
Model Model1
Mileage 10000
Age of car 2000

PLC_001A 1002
Call Date 19-Feb 2
Member no 123456-1234554322
CONTACT Mr John Smith
POST CODE XX77 7XX
Reg no X123 ABC
Make MN
Model Model2
Mileage 10000
Age of car 2000

PLC_001A 1003
Call Date 19-Feb 2
Member no 123456-1234554323
CONTACT Mr John Smith
POST CODE XX77 7XX
Reg no X123 ABC
Make MN
Model Model3
Mileage 10000
Age of car 2000

PLC_001A 1004
Call Date 19-Feb 2
Member no 123456-1234554324
CONTACT Mr John Smith
POST CODE XX77 7XX
Reg no X123 ABC
Make MN
Model Model4
Mileage 10000
Age of car 2000

what I'm trying to do is tranpose the data into a table:

PLC_001A Call Date Member no CONTACT POST CODE Reg no Make Model Mileage Age of car
1000 19-Feb 123456-1234554321 Mr John Smith XX77 7XX X123 ABC MN Model1 10000 2000
1002 19-Feb 123456-1234554322 Mr John Smith XX77 7XX X123 ABC MN Model2 10000 2000
1003 19-Feb 123456-1234554323 Mr John Smith XX77 7XX X123 ABC MN Model3 10000 2000
1004 19-Feb 123456-1234554324 Mr John Smith XX77 7XX X123 ABC MN Model4 10000 2000

One of the problems I have is that the Date and Postcode flow over 2 columns, the date is OK as the Feb ## is in date format, but Postcode needs to be in one cell.

Any Ideas?

Here the data I have:

={"PLC_001A",1000,0;"Call Date",37306,2;"Member no","123456-1234554321",0;"CONTACT","Mr John Smith",0;"POST CODE","XX77","7XX";"Reg no","X123 ABC",0;"Make","MN",0;"Model","Model1",0;"Mileage",10000,0;"Age of car",2000,0;0,0,0;"PLC_001A",1002,0;"Call Date",37306,2;"Member no","123456-1234554322",0;"CONTACT","Mr John Smith",0;"POST CODE","XX77","7XX";"Reg no","X123 ABC",0;"Make","MN",0;"Model","Model2",0;"Mileage",10000,0;"Age of car",2000,0;0,0,0;"PLC_001A",1003,0;"Call Date",37306,2;"Member no","123456-1234554323",0;"CONTACT","Mr John Smith",0;"POST CODE","XX77","7XX";"Reg no","X123 ABC",0;"Make","MN",0;"Model","Model3",0;"Mileage",10000,0;"Age of car",2000,0;0,0,0;"PLC_001A",1004,0;"Call Date",37306,2;"Member no","123456-1234554324",0;"CONTACT","Mr John Smith",0;"POST CODE","XX77","7XX";"Reg no","X123 ABC",0;"Make","MN",0;"Model","Model4",0;"Mileage",10000,0;"Age of car",2000,0}

And this is the required result:

{"PLC_001A","Call Date","Member no","CONTACT","POST CODE","Reg no","Make","Model","Mileage","Age of car";1000,37306,"123456-1234554321","Mr John Smith","XX77 7XX","X123 ABC","MN","Model1",10000,2000;1002,37306,"123456-1234554322","Mr John Smith","XX77 7XX","X123 ABC","MN","Model2",10000,2000;1003,37306,"123456-1234554323","Mr John Smith","XX77 7XX","X123 ABC","MN","Model3",10000,2000;1004,37306,"123456-1234554324","Mr John Smith","XX77 7XX","X123 ABC","MN","Model4",10000,2000}

Any help on this would fantastic!

many thanks.
Ian Mac is offline   Reply With Quote
Old Feb 21st, 2002, 07:21 AM   #2
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

This macro should help you.

Tip of the day for Sunday, February 10, 2002
http://www.mrexcel.com/weblog/weblog.shtml

It's not THE EXACT format you're asking for, but it should help.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Feb 21st, 2002, 09:21 AM   #3
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Thanks Juan,

I'm trying to adapt it to say copy 1 row and the next 10 then next line then 1 - 10,

if you could let me know what each line is doing exactly I might be able to work it out.

my code (not much differnce, yet)

Sub CopyAcross()

Dim i As Long
Dim NRow As Long
Dim LastRow As Long

Columns("C:C").Select
Application.CutCopyMode = False
Selection.Replace What:="2", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

NRow = 1 'First Row TO COPY, change this if you want
i = 1 'First Row where the data appears, I assumed it started in A2


LastRow = Range("A65536").End(xlUp).Row


While i <= LastRow
Range(Cells(i, 2), Cells(i, 2).End(xlDown)).Copy
Cells(NRow, 4).PasteSpecial Transpose:=True 'In here, I'm copying to Column 2, Next availabe Row. You can change the 2 if you want.
NRow = NRow + 1
i = Cells(i, 2).End(xlDown).End(xlDown).Row
Wend
End Sub

thanks
Ian Mac is offline   Reply With Quote
Old Feb 22nd, 2002, 01:36 PM   #4
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

Explanation, step by step:

Quote:
On 2002-02-21 08:21, Ian Mac wrote:
Thanks Juan,

I'm trying to adapt it to say copy 1 row and the next 10 then next line then 1 - 10,

if you could let me know what each line is doing exactly I might be able to work it out.

my code (not much differnce, yet)

Sub CopyAcross()

Dim i As Long
Dim NRow As Long
Dim LastRow As Long

Columns("C:C").Select
Application.CutCopyMode = False
Selection.Replace What:="2", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

NRow = 1 'First Row TO COPY, change this if you want
i = 1 'First Row where the data appears, I assumed it started in A2


LastRow = Range("A65536").End(xlUp).Row


While i <= LastRow
Range(Cells(i, 2), Cells(i, 2).End(xlDown)).Copy
Cells(NRow, 4).PasteSpecial Transpose:=True 'In here, I'm copying to Column 2, Next availabe Row. You can change the 2 if you want.
NRow = NRow + 1
i = Cells(i, 2).End(xlDown).End(xlDown).Row
Wend
End Sub

thanks
Range(Cells(i, 2), Cells(i, 2).End(xlDown)).Copy 'This goes to cell Row i Column B, and "presses" Control Shift Down, and then Copu it.

Cells(NRow, 4).PasteSpecial Transpose:=True 'Copy to Cell Row NRow, Column D, and transpose it (So it looks like one data row)

NRow = NRow + 1 'Increment NRow in 1, so it won't delete previous data.

i = Cells(i, 2).End(xlDown).End(xlDown).Row 'From Cell Row i, Column B, press Control Down, and again, Control Down (This should be the next "group" of data")

Wend 'Repeat this process until we're in the last row.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González 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 11:46 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