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 Jul 8th, 2004, 04:42 PM   #1
msampson
 
Join Date: Mar 2004
Location: Bethesda, MD
Posts: 34
Default macro help for rearranging data

Hi all
I'm trying to set up a macro to rearrange data from a microtiter plate reader.

There is an array of 12 columns (A-L) and 8 rows (starting with 4-11) that represents the wells in the plate. This same array is repeated 100 times with a blank row between each iteration. This represents each reading at increasing time points.
I have recorded a macro to add 12 worksheets to my workbook. I then copied each column A thru L onto a separate sheet in column A. Also on the starting sheet is a row (3) that is 100 columns wide containing the time of the read. I copied that and pasted it transposed into column B on each of the 12 worksheets that correspond to each column on the plate.
What I need to do now is to take each set of 8 rows (all in column A on each different worksheet) and transpose them into 8 columns (C-J) so that each row becomes each different time point indicated in column B.

Is that clear? Can you help please?
Thanks from a rookie macro person
Maureen
msampson is offline   Reply With Quote
Old Jul 9th, 2004, 01:31 AM   #2
GaryB
 
Join Date: Feb 2002
Location: Essex, England
Posts: 456
Default

Ok this is pretty lousy sample data for an example, but is this what your after? (It's getting late this side if the pond!)

******** ******************** ************************************************************************>
Microsoft Excel - Book1___Running: 11.0 : OS = Windows XP
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
E
F
G
H
I
J
1
*time11112131415161718
2
*time22122232425262728
3
*time33132333435363738
4
11time44142434445464748
5
12time55152535455565758
6
13time66162636465666768
7
14time7********
8
15time8********
9
16time9********
10
17time10********
11
18time11********
12
*time12********
13
21time13********
14
22time14********
15
23time15********
16
24time16********
17
25time17********
18
26time18********
19
27time19********
Sheet1*

[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


The data starts of in columns A& B, and gets copied to C-J

If thats right then this should work for you


Code:
Sub Macro3()

Dim i As Integer
   For i = 1 To 100
    j = 9 * (i - 1) + 4
   Range("A" & j, "A" & j + 7).Copy
   Range("C" & i).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
    Next i
End Sub

Hope this helps

GaryB
GaryB is offline   Reply With Quote
Old Jul 9th, 2004, 04:42 PM   #3
msampson
 
Join Date: Mar 2004
Location: Bethesda, MD
Posts: 34
Default Re: macro help for rearranging data

what you show in the sample data is correct but when I try to run that macro I get a syntax error on the line For i= 1 To 100
?????
msampson is offline   Reply With Quote
Old Jul 9th, 2004, 05:29 PM   #4
GaryB
 
Join Date: Feb 2002
Location: Essex, England
Posts: 456
Default

I cannot understand that at all. As far as I can see there's nothing wrong with the line (there's hardly a lot of it to go wrong!). I've just copy/pasted the macro back off the board and onto my test sheet and it runs without any problem. Try recopying it, maybe something got mangled in the pasting.

Failing that try stepping through the macro (use F8) and make sure it is that line that's causing the problem, but I really can't see how!

HTH

GaryB
GaryB is offline   Reply With Quote
Old Jul 9th, 2004, 05:51 PM   #5
msampson
 
Join Date: Mar 2004
Location: Bethesda, MD
Posts: 34
Default Re: macro help for rearranging data

I erased it and closed out the files. Opened the file again, opened the vba editor and pasted the code into a new black code window and tried it again. If I run my recorded macro first, then choose one of the pages with the 2 columns of data and try to run it I get the syntax error. I opened a new workbook and copied just the two columns of data and tried it and got the same thing. This time, nothing is highlighted but all the text is red except the line
Range("A" & j, "A" & j + 7).Copy
is in black and the first two and last line are in dark blue.

Sorry to be so obtuse - I'm just not that experienced in macros.
msampson is offline   Reply With Quote
Old Jul 9th, 2004, 06:06 PM   #6
GaryB
 
Join Date: Feb 2002
Location: Essex, England
Posts: 456
Default

Ok, let's make sure the code is in the right place.
Open your VB editor.
On the left (usually!) there is the Project Explorer Window (it's title bar probably says "Project-VBA Project")
Select your spreadsheet in there - if it's got a + next to it click on that to expand it. Have you got a Modules folder at the bottom? (If not go to the Insert menu and select Module.
Modules should now have a Module 1 in it) Double click on Module 1 and copy paste your macro in there.
Try running it from there. Make sure you have a suitable sheet of your workbook active arrange the windows so you can see both Excel and the VB editor and you can step through the macro using F8.

HTH

GaryB
GaryB is offline   Reply With Quote
Old Jul 9th, 2004, 07:38 PM   #7
msampson
 
Join Date: Mar 2004
Location: Bethesda, MD
Posts: 34
Default Re: macro help for rearranging data

nope.
compile error:
syntax error.

I tried both pasting it in the module window after the recorded macro and on a separate workbook by itself (with the data arranged as if by the recorded part).

Ummm, I'm working on a Macintosh if that makes a difference? A G5 dp with OS X. I have both Excel X and Excel 2004 available. I've been trying this with Excel X so far.
msampson is offline   Reply With Quote
Old Jul 10th, 2004, 01:00 AM   #8
GaryB
 
Join Date: Feb 2002
Location: Essex, England
Posts: 456
Default

I've never used Excel on a Mac.(actually I haven't used a Mac for years) I wouldn't have thought that something as basic as a For Next loop would have different syntax, but it might be worth checking in the help files in VBA.
I have no idea if it will make a difference, but it can't do any harm to try it in 2004. Beyond that I'm afraid I run out of ideas.

I've posted up a help request on http://www.mrexcel.com/board2/viewto...=466561#466561 It would probably be worth you putting a watch on that thread as well, in case some answers come in before I get a chance to look again. Someone on the Board is bound to know the answer.
Sorry I can't be much help


GaryB
GaryB is offline   Reply With Quote
Old Jul 12th, 2004, 03:06 PM   #9
GaryB
 
Join Date: Feb 2002
Location: Essex, England
Posts: 456
Default

Maureen,
have you tried running this on your 2004 Excel version yet? MarkW has managed to run the code and so has a friend of mine I sent my test sheet to.
If you need to run this on a your 98 version, can you tell me what the help file says about For..Next loops and I may be able to adjust the syntax to suit.

Cheers

GaryB
GaryB is offline   Reply With Quote
Old Jul 12th, 2004, 08:06 PM   #10
msampson
 
Join Date: Mar 2004
Location: Bethesda, MD
Posts: 34
Default Re: macro help for rearranging data

It doesn't run (for the same reason) on Excel 2004, Excel 98 or I even tried it on our Citrix server which should be PC Excel. I even got the syntax error on the Citrix Excel which looks to be Excel 2002.

Is there a different way of writing the code?
Maureen
msampson 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 +1. The time now is 03:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2010 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