473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Transpone Data

I have data in column A and i would like to copy 9 rows in that column then transpose the data in column I-R and and contunie to the next 9 rows and transpone again until it reaches the last row in column A. Then once the last part is reached delete column A AND B. I tryed to record a macro to do this but it wont loop on its own and keep going it stops after the first one the i have to press short cut key to move to the next one doing it like that could take a really long time

Thanks to any one who can help...
Nov 30 '11 #1
10 1465
Guido Geurs
767 Expert 512MB
Put the range in an array and dump the array in the other column at the right row.
This will transpose blocks of 9 rows in column A to column D and delete columns A and B.

Expand|Select|Wrap|Line Numbers
  1. Sub Transpose()
  2. Dim ARRTRANS As Variant
  3. Dim ROWidx As Integer
  4.     ROWidx = 1
  5.     Do Until Cells(ROWidx, 1) = ""
  6.         ARRTRANS = Range("A" & ROWidx).Resize(9)
  7.         Range("D" & ROWidx).Resize(9) = ARRTRANS
  8.         ROWidx = ROWidx + 9
  9.     Loop
  10.     Columns("A:B").Select
  11.     Selection.Delete
  12. End Sub
  13.  
Dec 2 '11 #2
Thanks Guido for the response I didnt mentions that there is black row after each block... thanks for the code for this. I do i skip the blanck row???
Attached Files
File Type: zip Bytes.com.zip (80.6 KB, 82 views)
Dec 2 '11 #3
Guido Geurs
767 Expert 512MB
This will skip the blanco rows (if there are no more than 2 !)
Expand|Select|Wrap|Line Numbers
  1. Sub Transpose()
  2. Dim ARRTRANS As Variant
  3. Dim LASTROWidx As Integer
  4. '§ look for last row with data
  5.     LASTROWidx = 1
  6.     Do Until Cells(LASTROWidx + 1, 1) = "" And _
  7.             Cells(LASTROWidx + 2, 1) = "" And _
  8.             Cells(LASTROWidx + 3, 1) = ""
  9.         LASTROWidx = LASTROWidx + 1
  10.     Loop
  11. '§ put data in array
  12.     ARRTRANS = Range("A1").Resize(LASTROWidx)
  13. '§ dump data in new column
  14.     Range("D1").Resize(LASTROWidx) = ARRTRANS
  15. '§ delete 2 first columns
  16.     Columns("A:B").Select
  17.     Selection.Delete
  18. End Sub
  19.  
Dec 3 '11 #4
Hey Guido thanks for the reaspone! when i added the code above it worked fot the first set of data but then never did the other ones. after each set of 9 blocks there is a blank row. I appreciate the help alway!!! your the best :-)
Dec 3 '11 #5
Guido Geurs
767 Expert 512MB
Is it on sheet 3 to do the transpose?
The attached file was open on sheet 3.
If there are more blanco lines than 2 then you have to increase the check for blanco cells. for 5 blanco lines it must be:
Expand|Select|Wrap|Line Numbers
  1. Sub Transpose()
  2. Dim ARRTRANS As Variant
  3. Dim LASTROWidx As Integer
  4. '§ look for last row with data
  5.     LASTROWidx = 1
  6.     Do Until Cells(LASTROWidx + 1, 1) = "" And _
  7.             Cells(LASTROWidx + 2, 1) = "" And _
  8.             Cells(LASTROWidx + 3, 1) = "" And _
  9.             Cells(LASTROWidx + 4, 1) = "" And _
  10.             Cells(LASTROWidx + 5, 1) = ""
  11.         LASTROWidx = LASTROWidx + 1
  12.     Loop
  13. '§ put data in array
  14.     ARRTRANS = Range("A1").Resize(LASTROWidx)
  15. '§ dump data in new column
  16.     Range("D1").Resize(LASTROWidx) = ARRTRANS
  17. '§ delete 2 first columns
  18.     Columns("A:B").Select
  19.     Selection.Delete
  20. End Sub
PS:
In this code there is no transpose of blocks of 9 lines but of the complete column.

Must it be in blocks of 9 lines???
Dec 3 '11 #6
Hello Guido thats for the reaspone... It still is only working for the first set of 9 blocks I am going to work on it more this afternoon. Thanks for your help... ;-)
Dec 5 '11 #7
Guido Geurs
767 Expert 512MB
it has transposed all the 999 lines for sheet 3.(see attachment)
Attached Files
File Type: zip Careermd1_v3.zip (74.7 KB, 55 views)
Dec 5 '11 #8
Guido... Ahhh what im i doing wrong???? I am not getting it to transpone for me I dont know why??? I looked at you attachment but it is not working for me!! i was i had your coding abilty...
Dec 5 '11 #9
Guido Geurs
767 Expert 512MB
I have tested the last attachment on Vista and Office2007 and it's working fine for me.
What is going wrong on your Excel file?
Dec 6 '11 #10
I dont know What is wrong with it only does the first row and thats it. Thanks Guido I am going to work on today and try to firgure it out i will give you any update once i got it thanks Once again :-)
Dec 6 '11 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
11
by: Qiangning Hong | last post by:
A class Collector, it spawns several threads to read from serial port. Collector.get_data() will get all the data they have read since last call. Who can tell me whether my implementation correct?...
0
by: Eric | last post by:
I've got a weird problem, regardless of how often I enter: perl -MCPAN -e 'install "Data::Dumper"' I never get a message telling me that it is up-to-date. It will always try to reinstall even...
7
by: Will | last post by:
On the subject of Data Warehouses, Data Cubes & OLAP…. I would like to speak frankly about Data Warehouses, Data Cubes and OLAP (on-line analytical processing). Has it dawned on anyone else...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
3
by: bbernieb | last post by:
Hi, All, Is it possible to access a variable inside of a data binding, without the variable being out of scope? (Note: On the DataBinder line, I get an error message that says "Name 'i' is...
5
by: Gene | last post by:
What can I do if I want to get the result using the sql command? for example, the select command is "select Name from Employee where StaffID=10" How to get the "Name"??? dim Name as string and...
5
by: DC Gringo | last post by:
I am having a problem reading a simple update to the database. Basically I'm testing a small change to the pubs database -- changing the price of the Busy Executive's Database Guide from 19.99 to...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: Winder | last post by:
Computer Data Recovery Help 24/7 Data recovering tools and services is our focus. We will recover your data in a cost effective and efficient manner. We recover all operating systems and media....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.