Help with macro to transpose data

I am in need of a macro to transpose rows into columns. I have been trying to figure it out with no success.
My data is in the format
1
A
B
C
x
y
z
2
D
E
F
p
q
r
3
G
H
I
m
n
o
and i need it to repeat the first few columns of each row but transpose the last few, so that,
1
A
B
C
x
1
A
B
C
y
1
A
B
C
z
2
D
E
F
p
2
D
E
F
q
2
D
E
F
r
3
G
H
I
m
3
G
H
I
n
3
G
H
I
o
This needs to repeat over 400 times. There are more columns then what i showed but I should be able to modify the code to make it work. If any one can help me I would be very thankful.
-Carl

Hi Carl,
Here is a sample code is for you reference. It should be able to achieve what your described, but not an elegant way.
Option Explicit
Sub test()
Dim arr, arr1, i&, j&, h&
Worksheets("sheet2").Cells.ClearContents
With Worksheets("sheet1")
arr = .Range("A1:G" & .[a10000].End(xlUp).Row)
End With
ReDim arr1(1 To UBound(arr) * 3, 1 To 5)
For i = 1 To UBound(arr)
    For j = 1 To 4
    h = (i) + (i - 1) * 2
    arr1(h, j) = arr(i, j)
    arr1(h + 1, j) = arr(i, j)
    arr1(h + 2, j) = arr(i, j)
    arr1(h, 5) = arr(i, 5)
    arr1(h + 1, 5) = arr(i, 6)
    arr1(h + 2, 5) = arr(i, 7)
    Next
Next
Worksheets("sheet2").[a1].Resize(UBound(arr1), 5) = arr1
End Sub
Wind Zhang
TechNet Community Support

Similar Messages

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Help with hours between two dates

    Hi I need help with the below query
    select count(*),a.col1,max(a.dt),min(a.dt)
    from tab1 a
    where a.dt > to_date('01-JUL-08','dd-mon-yyyy')
    group by col1
    having count(*) >=2
    and (max(a.dt) - min(a.dt))* 24*60*60 > 360;
    I am trying to pull the records with more than 2 entries, and having more than 6 hrs difference between max date and min date. When I am trying to execute this I am getting an error at "(max(a.dt) - min(a.dt))* 24*60*60 > 360".
    any ideas how can I pull the records more than 6 hrs?
    Thanks in advance!

    Sorry guys...here is the erros i am getting
    ORA-00932: inconsistent datatypes: expected INTERVAL DAY TO SECOND got NUMBER
    my version : 9.2
    SQL>
    SQL> @ver
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE    9.2.0.8.0       Production
    TNS for Solaris: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    SQL>
    SQL>
    SQL> --
    SQL> drop table tab1;
    Table dropped.
    SQL> create table tab1 as
      2    select 'stin_8723646' as col1, to_date('7/22/2008 5:48:32 AM', 'mm/dd/yyyy hh:mi:ss AM') as dt from dual union all
      3    select 'stin_8723646', to_date('7/22/2008 1:34:12 PM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
      4    select 'stin_8723646', to_date('7/22/2008 3:16:25 PM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
      5    select 'stin_8723647', to_date('7/22/2008 1:10:07 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
      6    select 'stin_8723647', to_date('7/22/2008 4:19:00 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
      7    select 'stin_8723647', to_date('7/22/2008 9:52:44 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual;
    Table created.
    SQL>
    SQL> alter session set nls_date_format = 'mm/dd/yyyy hh:mi:ss am';
    Session altered.
    SQL>
    SQL> select * from tab1;
    COL1         DT
    stin_8723646 07/22/2008 05:48:32 am
    stin_8723646 07/22/2008 01:34:12 pm
    stin_8723646 07/22/2008 03:16:25 pm
    stin_8723647 07/22/2008 01:10:07 am
    stin_8723647 07/22/2008 04:19:00 am
    stin_8723647 07/22/2008 09:52:44 am
    6 rows selected.
    SQL>
    SQL> --
    SQL> select
      2    count(*),
      3    a.col1,
      4    max(a.dt),
      5    min(a.dt)
      6  from tab1 a
      7  where a.dt > to_date('01-JUL-08','dd-mon-yyyy')
      8  group by col1
      9  having count(*) >=2
    10  --and (max(a.dt) - min(a.dt))* 24*60*60 > 360
    11  and (max(a.dt) - min(a.dt))* 24 > 6;
      COUNT(*) COL1         MAX(A.DT)              MIN(A.DT)
             3 stin_8723646 07/22/2008 03:16:25 pm 07/22/2008 05:48:32 am
             3 stin_8723647 07/22/2008 09:52:44 am 07/22/2008 01:10:07 am
    SQL>
    SQL>isotope

  • Help with Capturing Business Graphics data point

    Hi,
    I created a BusinessGraphics UI element with SimpleSeries and assigned eventId for the categories and data points. I am able to get the series that is clicked through the event but I would like to know which point (value) is clicked as well.
    The steps I followed are
    1. Created BG UI element, category and SimpleSeries
    2. Assigned eventIDs
    3. Created an action class and mapped it to the UI element
    4. Code in wdDoModifyView is
         if (firstTime)
           IWDBusinessGraphics chart = (IWDBusinessGraphics) view.getElement("bgCSB");
           chart.mappingOfOnAction().addSourceMapping("id", "pointID");
    5. Implemented action class with one parameter (pointID) and able to get the value.
    Can someone help me to get the data point values from the user click.
    Appreciate your help.
    Thanks,
    Kalyan

    You have done everything right, except I don't think you can do this with simple series.
    Create something like this:
    in the context:
    series-> (this node can be with 1..1 cardinality and 1..1 selection)
       points->
           label (string)
           value (int)
           pointId (string)
    in the business graphics:
    create one series (not simple one) and add to it one point of numeric type.
    in the properties of business graphics bind seriesSource to series context.
    Series: bined poitSource to series.points
    Series_points: bind eventId to series.points.pointId
                            bind label to series.points.label
                            bind valueSource to series.points
    Values (these are the numeric values): bind value to series.points.value
    in wdDoModify method do the same thing as you have done already.
    Now, when you click on a point you will receive in your event in pointId variable the pointId context attribute value.
    Best regards,
    Anton

  • Help with CF Reports and Dates

    Can anyone here help me with
    This
    post ? I have been waiting for 3 days and after 4 posts no one
    has been able to answer, please help!! I'm stuck on my project only
    because of this. Thank you very, very much.
    Nelson.

    Sorry, I don't use cfreport so I would not be any help with
    what may be inside the total_sales_report_by_date.cfr template.
    However, shouldn't you be executin your query inside of your .cfm
    emplate, then passing the query result to your report as a query
    parameter within your cfreport tag, rather than passing the date
    parameters in cfreportparam tags?
    Phil

  • Help with reloading back up data

    I had to restore my bb pearl 8120 the other day.  Backed up all data and then had a few problems with it.  I have now managed to sort it all but cant reload all my backed up data, I have lost a lot of phone number that I really need.
    Any help with this would be fab.
    Thanks

    Hello,
    Please provide more details, such as:
    Specific BB Model (8120)
    Specific BB OS level (all 4 octets)
    Specific Desktop Software level (also 4 octets)
    Carrier
    Country
    The specific symptoms you witnesses -- "cant reload all my backed up data" doesn't tell us much. Specific details of exactly the steps you attempt and exactly the results you see would be helpful.
    Thanks!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Help with converting hex to date and time

    Hi!
    I am using snmp4j libraries to walk the mib tree. The system date is getting returned in 11 hexadecimal octets. I require help in converting it to date and time. I looked up the RFC convention of what each octets represent. Require help with conversion.
    Eg: 07:db:06:0a:29:1d:00:2b:05:1e
    Thanks,

    Octets Contents Range
    1-2 year 0..65536
    3 month 1..12
    4 day 1..31
    5 hour 0..23
    6 minutes 0..59
    7 seconds 0..60
    (use 60 for leap-second)
    8 deci-seconds 0..9
    9 direction from UTC '+' / '-'
    10 hours from UTC 0..13
    11 minutes from UTC 0..59
    For example I just took the time an hour ago it came out as
    07:db:06:13:12:11:1a:00:2b:05:1e
    I have to convert this as a date long value to send it.
    Do I have to write an utility of my own to do it?

  • Urgent-Need help with code for Master data enhancement

    hi Experts,
    I have appended YMFRGR field(Table MARC) to 0MAT_PLANT_ATTR datasource.
    The key fields in the MARC table are MATNR and WERKS.Can anybody help with the user exit to populate this field,as am pretty new to ABAP.
    Thanks in advance

    Hi,
    go through this link which has the similar problem:
    https://forums.sdn.sap.com/click.jspa?searchID=1331543&messageID=2794783
    hope it helps.
    Thanks,
    Amith

  • Help with form sending the data to email

    I have looked all over the Internet for help with this.  I have tried numerous video tutorials and for some reason I can't get it to work.  I have created a form in flash cs4 AS2.  It is a contact information form where the user fills out their information and sends it.  I have created a the form in a movie clip (I have also tried it not in a movie clip) with the form components inside that movie clip.  I have given each component on the form an instance name.
    The form has:
    Full name (with instance name=name)
    Company (with IN =company)
    Title (with IN = title)
    Phone (with IN = phone)
    Email (with IN = email)
    Topic combobox (with IN=topic)
    Message box (with IN=msg)
    Submit button (with IN=submit)
    I need help with the actionscript writing.  I am VERY new to flash and have never done any scripting really.  Does anyone have a sample file I can look at to see how it works or can someone IM me and I can send my file for them to help me?
    My IM is logan3975
    Any help is greatly appreciated.  I consider myself a pretty technical person so I do learn quick...I just need some guidance until I wrap my head around how this all works.  Thanks.

    Here's a link to a posting elsewhere some had had that may provide some useful info (?)
    http://board.flashkit.com/board/showthread.php?t=684031

  • Help with selecting chuncks of data from a table

    Hi all,
    I need help with a query that should do the following.
    I have a table with vessel messages, and I need to get the last "NumMsgs" messages from a group of vessels.
    The problem I have is that if I order the table by Vessel_ID, MessageDate DESC, I can´t do ROWNUM < NumMsgs (<-- Then number of messages to be shown is a user parameter)
    I know it should be something like:
    select * from (
    select *
    from Messages m
    where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
    order by m.V_ID, m.MESSAGEDATE desc
    where rownum < :NumMsgs
    Any ideas?
    Thanks in advance !

    Hi,
    What about :
    select *
    from (
    select m.*, row_number() (order by m.V_ID, m.MESSAGEDATE desc) rn
    from Messages m
    where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
    where rn < :NumMsgsAnyway, I don't very well understand your problem, your query work fine, see for example :
    SQL> ed
    Wrote file afiedt.buf
      1  select object_name, object_id
      2  from
      3  (select object_name, object_id, row_number() over (order by object_id desc) as rn
      4   from dba_objects)
      5* where rn < 4
    SQL> /
    PS_TL_MTCHD_118     71763
    PS_TL_MTCHD_117     71762
    PS_TL_MTCHD_116     71761
    SQL> ed
    Wrote file afiedt.buf
      1  select object_name, object_id
      2  from
      3  (select object_name, object_id
      4   from dba_objects
      5   order by object_id desc)
      6* where rownum < 4
    SQL> /
    PS_TL_MTCHD_118     71763
    PS_TL_MTCHD_117     71762
    PS_TL_MTCHD_116     71761
    SQL> Nicolas.
    Message was edited by:
    N. Gasparotto

  • In need of a macro to transpose data from horizontal to vertical

    I need help creating  a macro that would transpose some data from horizontal to vertical. 

    You just want to transpose some data from horizontal to vertical?
    If so ,you can use array formula TRANSPOSE.
    Also here is a sample Macro:
    Sub Macro1()
    ' Macro1 Macro
    Range("A1:B3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("H1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    End Sub
    It would be better if you can let us know your current data and what you are trying to achieve.
    Wind Zhang
    TechNet Community Support

  • Help with exporting forms based data to Excel 2007

    I have a user who is attempting to export forms based data to Microsoft Excel 2007 and when he attempts this he receives a message stating that Windows does not recognise this file type (tsv). I am not too familiar with Office 2007 so I am unable to direct this users as to how to correct this issue.
    Is someone able to give me the navigation path to help me to assist this user? thanks

    Did you verify the file type from Windows Explorer?
    1) Right click on My Computer > Explore
    2) Go to Tools > Folder Options
    3) Click on File Types tab
    4) Check if TSV file is defined there or not. If it is not there, click on New and add the File Extension

  • Need help with RANK() on NULL data

    Hi All
    I am using Oracle 10g and running a query with RANK(), but it is not returning a desired output. Pleas HELP!!
    I have a STATUS table that shows the history of order status.. I have a requirement to display the order and the last status date (max). If there is any NULL date for an order then show NULL.
    STATUS
    ORD_NO | STAT | DT
    1 | Open |
    1 | Pending |
    2 | Open |
    2 | Pending |
    3 | Open |1/1/2009
    3 | Pending |1/6/2009
    3 | Close |
    4 | Open |3/2/2009
    4 | Close |3/4/2009
    Result should be (max date for each ORD_NO otherwise NULL):
    ORD_NO |DT
    1 |
    2 |
    3 |
    4 |3/4/2009
    CREATE TABLE Status (ORD_NO NUMBER, STAT VARCHAR2(10), DT DATE);
    INSERT INTO Status VALUES(1, 'Open', NULL);
    INSERT INTO Status VALUES(1, 'Pending', NULL);
    INSERT INTO Status VALUES(2, 'Open', NULL);
    INSERT INTO Status VALUES(2, 'Pending',NULL);
    INSERT INTO Status VALUES(3, 'Open', '1 JAN 2009');
    INSERT INTO Status VALUES(3,'Pending', '6 JAN 2009');
    INSERT INTO Status VALUES(3, 'Close', NULL);
    INSERT INTO Status VALUES(4, 'Open', '2 MAR 2009');
    INSERT INTO Status VALUES(4, 'Close', '4 MAR 2009');
    COMMIT;
    I tried using RANK function to rank all the orders by date. So used ORDER BY cluse on date in descending order thinking that the null dates would be on top and will be grouped together by each ORD_NO.
    SELECT ORD_NO, DT, RANK() OVER (PARTITION BY ORD_NO ORDER BY DT DESC)
    FROM Status;
    ...but the result was something..
    ORD_NO |DT |RANKING
    *1 | | 1*
    *1 | | 1*
    *2 | | 1*
    *2 | | 1*3 | | 1
    3 |1/6/2009 | 2
    3 |1/1/2009 | 3
    4 |3/4/2009 | 1
    4 |3/2/2009 | 2
    I am not sure why didn't the first two ORD_NOs didn't group together and why ranking of 1 was assigned to them. I was assuming something like:
    ORD_NO |DT |RANKING
    *1 | | 1*
    *1 | | 2*
    *2 | | 1*
    *2 | | 1*
    3 | | 1
    3 |1/6/2009 | 2
    3 |1/1/2009 | 3
    4 |3/4/2009 | 1
    4 |3/2/2009 | 2
    Please guide me if I am missing something here?
    Regards
    Sri

    Hi,
    If i well understood, you don't need rank
    SELECT   ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
        FROM status
    GROUP BY ord_no
    SQL> select * from status;
        ORD_NO STAT       DT
             1 Open
             1 Pending
             2 Open
             2 Pending
             3 Open       2009-01-01
             3 Pending    2009-01-06
             3 Close
             4 Open       2009-03-02
             4 Close      2009-03-04
    9 ligne(s) sélectionnée(s).
    SQL> SELECT   ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
      2      FROM status
      3  GROUP BY ord_no;
        ORD_NO DT
             1
             2
             3
             4 2009-03-04
    SQL>

  • Need help with code for adding dates to form

    Hello forum goers
    I'm new to making forms and figured out how to auto add the date, however I need the form to change the date for every copy made.
    For example today is 06/08/2012 if I print 10 copies of the form it will output 10 pages ranging from 06/08/2012 to 06/17/2012. If code exists to do this I would be very gratefull to whoever helps, I also wouldn't mind if that is not possible for manually inputing the start / end dates.
    Currently I print 15-30 copies of the form and hand write each of the dates but I'm just getting to busy to do that. I also cannot print one a day it must be in batches.
    Thanks in advanced.

    What you are asking for is more complex than just setting the current date. Each time the form prints it has to know that it has to change the date. I would suggest doing this.
    First, setup a document level script to set the date to the current date. I suspect that you have already done this?
    Next, Create a "DidPrint" document action to increment the date.  To do this the script will need to scan the current text value of the date, add one day to it, and then reformat it.  You'll find information on this type of scripting in these articles:
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-2
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-3
    Since the increment happenes in the Did Print you will need to print each copy individually. If you enter 10 copies in the print dialog it won't work. You have to print one at a time.  You can automate this activity with a console script.
    One of the advantages of incrementing in the DidPrint is that you can also manually enter a date and it will increment from there.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)
    Having trouble, Why Doesn't my Script Work?

  • Ipod Touch , Help with keeping pics after data loss

    Ok well , a couple of weeks ago one of the HDDs in my raid array went down and I lost a fair bit of data , I dont care about the songs/videos etc but some 700+ photos I had on the drive from holidays/birthdays etc I was really upset about.
    Yes I know I should've had backups but I didnt so no point going there , now I have all the photos on my ipod touch 2g but now when I replaced my drive , re-installed XP and so on iTunes sees the ipod as synced with another iTunes which is obviously now inaccessible and wants to delete everything on the IPod and sync it with this new itunes.
    Basically is there anyway I can keep my pictures on there or retrieve them from the ipod ????
    Please help
    Thx in advance
    Lee

    you have to change the ipod into manually manage then you can get access i have both my ipods that way and it wont ask to delete everything but thats just me i have had my 5th gen and my touch this way but the only thing i do not have set up this way would be my ipod shuffle.. so yeah ..just try to fingure out had to manually manage the ipod and u should beable to get your pictures off the ipod..good luck
    Don't Worry!!Be Happy
    Message was edited by: BerryAngel

Maybe you are looking for