+ Reply to Thread
Results 1 to 30 of 30

Transpose Array VBA Script

  1. #1
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Transpose Array VBA Script

    I had come previously for help with a formula in This Post.

    1.
    The formula seemed to have been working at the time, however once I added to it and began testing it using multiple inputs, it stopped properly working. It would only convert, transpose, and format the first input, multiple times in the outputted area.

    What the output is suppose to look like
    Please Login or Register  to view this content.
    What the output actually looks like.
    Please Login or Register  to view this content.
    2.
    Originally, the VBA script was to...
    1. Take the inputs, each located in their own cell in the first worksheet
    2. Convert them from their comma deliminated format
    3. Transpose them into the second worksheet
    4. Format them by deleting cells, moving infromation around etc.
    5. Go on to the next input and repeat the process.

    3.
    Example Input Located in a Single Cell
    Please Login or Register  to view this content.

    Current VBA Script
    Please Login or Register  to view this content.
    4.

    Additionally I have attached a copy of the excel sheet to this post.

    Attachment 342729

    I appreciate any and all help. Thank you!

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Transpose Array VBA Script

    Use following statement to transpose your respective array..
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  3. #3
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by Vikas_Gautam View Post
    Use following statement to transpose your respective array..
    Please Login or Register  to view this content.
    I apologize, I may not have used the correct wording in my post.
    The script currently moves everything in the array properly, from the first worksheet to the new format in the second. This is not an issue.

    The issue is that the script only seems to work properly for the first cell in the first worksheet, and ignores all other input cells, while outputting the results from the first cell multiple times.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Transpose Array VBA Script

    The attachment is invalid apparently, could you try it again?
    If posting code please use code tags, see here.

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    This attachment link does not work.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  6. #6
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by Norie View Post
    The attachment is invalid apparently, could you try it again?
    Quote Originally Posted by Izandol View Post
    This attachment link does not work.
    Reattaching. Sorry about that!

    Transpose Array.xlsm

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Transpose Array VBA Script

    As far as I can see you never change the input range, it's always A1.

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    I do not think your data is well delimited. If all delimiters were present I believe you may use code like this:
    Please Login or Register  to view this content.
    Edited: I do now see you do not require only each second column!
    Last edited by Izandol; 09-02-2014 at 12:01 PM.

  9. #9
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by Norie View Post
    As far as I can see you never change the input range, it's always A1.
    I set a new variable called InputCount and tried using it to change the row every time the script loops.
    However keep getting a debugging error on the following line.

    For Each cl In Sheets("Input").Range("A" & InputCount).Resize(Sheets("Input").Range("A" & Rows.Count).End(xlUp).Row)

    I apologize I am a bit new to programming in general, and have been teaching myself VBA, starting with this script.

    Here is what the new script looks like.

    Please Login or Register  to view this content.





    "For Each cl In Sheets("Input").Range("A" & InputCount).Resize(Sheets("Input").Range("A" & Rows.Count).End(xlUp).Row)

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Transpose Array VBA Script

    In the Split function you should be using cl rather than Range("A1").

  11. #11
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    Problem is here:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    I changed the line to X = Split(Range(cl).Value, ",") , however am still getting the debugging error I mentioned above.

    Thank you for all your help so far! Its greatly appreciated.

  13. #13
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    Use original code with only that line changed. You do not give InputCount a value in this code so you refer to range A0.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Transpose Array VBA Script

    Please Login or Register  to view this content.
    The variable InputCount is never initialized, so its value is 0, so you're referencing cell A0, which doesn't exist.

    You set Count three times, though.
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    The new script causes the output to begin in the C column instead of the A column.


    Additionally if I re-enable these lines of code that I use for formatting, I get a debug error on the following line.

    Set rngDst = rngDst.Offset(1)

    Formatting
    Please Login or Register  to view this content.



    Here is a updated copy of the full script.

    Please Login or Register  to view this content.
    Last edited by King_Yoshi; 09-02-2014 at 12:54 PM.

  16. #16
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Please don't miss my last post on page 1! Thank you!

    Quote Originally Posted by Izandol View Post
    I do not think your data is well delimited. If all delimiters were present I believe you may use code like this:
    Please Login or Register  to view this content.
    Edited: I do now see you do not require only each second column!
    I believe I missed this post when I responded earlier.

    Yes I understand that the input is not well deliminated. However, I have no control over this, since the put is given to me as is and I am trying to find a way to organize it into something more legible.

    But thank you for the suggestion!

  17. #17
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Does anyone have any ideas regarding the aforementioned "invalid or qualified reference" error that I am getting?
    The debugger stops on line Set rngDst = rngDst.Offset(1).

  18. #18
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    You may try:
    Please Login or Register  to view this content.
    Last edited by Izandol; 09-02-2014 at 04:24 PM. Reason: correction

  19. #19
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    I tried running your script however received a compile error.

    Please see the below screenshot.

    compile error.png

  20. #20
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    I left a mistake - i have corrected it now.

  21. #21
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by Izandol View Post
    I left a mistake - i have corrected it now.
    I am still receiving the following error. (I copied your updated version of the code)

    compile error 2.png

    And then debugger brings me to the following line of code: Count = rngDest.Row

  22. #22
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    This is very bad - I left another mistake! Corrected once more.

  23. #23
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by Izandol View Post
    This is very bad - I left another mistake! Corrected once more.

    Thank you for being so patient with me!

    However, I am still receiving the same error from my previous post but on a different line of code.

    Set rngDst = rngDst.Offset(1)

    Once again, thank you for your patients and for taking so much of your time to help with this!

  24. #24
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Transpose Array VBA Script

    it's deleting the range-try:
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  25. #25
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Transpose Array VBA Script

    Thank you, Josie. I think I must have some sleep now so I do not provide more foolish answers!

  26. #26
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by JosephP View Post
    it's deleting the range-try:
    Please Login or Register  to view this content.
    Thank you for your help, however I am receiving this error from your script, and the debugger stops on this line.

    compile error 3.png

    For Each cl In Sheets("Input").Range("A" & InputCount).Resize(Sheets("Input").Range("A" & Rows.Count).End(xlUp).Row)

    Thank you, Josie. I think I must have some sleep now so I do not provide more foolish answers!
    It's ok! I really appreciate all the effort you put forth in trying to help me with this script!
    Enjoy your rest.

  27. #27
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Transpose Array VBA Script

    well it's way too early for me to go to bed :-)
    my bad-that line oughta be
    Please Login or Register  to view this content.

  28. #28
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    Quote Originally Posted by JosephP View Post
    well it's way too early for me to go to bed :-)
    my bad-that line oughta be
    Please Login or Register  to view this content.
    Wohoo!!!! It works!!

    Thank you very much for all your help!!

    I also want to thank everyone else who also helped.

  29. #29
    Registered User
    Join Date
    08-04-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    19

    Re: Transpose Array VBA Script

    I am now going to spend some time reading through the script. I may have some questions relating to how it works.
    I believe that I should at least understand your hard work if I am to use it.

  30. #30
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Transpose Array VBA Script

    Try the attached.

    If this is not how you wanted, just ignore it.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Script Group transpose - Error 13
    By marcushb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2013, 06:02 AM
  2. [SOLVED] How to transpose a bidimenional array
    By nemo66ro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2012, 07:10 AM
  3. [SOLVED] Transpose an Array
    By Aphyx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2012, 10:51 AM
  4. Conditional transpose to Array
    By reachthepalace in forum Excel General
    Replies: 0
    Last Post: 03-01-2006, 06:36 PM
  5. Script to transpose column addresses to rows
    By PAINE in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2005, 03:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1