Transpose columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Myriam Kwek

    Transpose columns

    I have the following data, in a single column:

    C1.1
    5.76E-10
    Undeveloped
    No
    O/C

    C10
    1.49E-9
    Basic
    No
    S/C

    C10.1
    1.49E-9
    Undeveloped
    No
    O/C. Sin efecto.

    I want to transpose it to columns, in the following way:

    C1.1 5.76E-10 Undeveloped No O/C
    C10 1.49E-9 Basic No S/C
    C10.1 1.49E-9 Undeveloped No O/C. Sin efecto.

    That is, C1.1, C10, and C10.1 in one column, the numbers in the column next to it, Undeveloped, Basic, Undeveloped in the column next to it, etc.

    I thought of the following:

    - Start at the first cell in the column
    - Cut the first 5 cells and place them in a row (transpose)
    - When you hit a blank row, cut the cells below it and place them underneath the first row that was transposed.

    I'm new to visual basic, and I don't know how to implement it. Thanks
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    It sounds like you are using Excel. I would first recommend learning to record macros and editing them. While recording a macro, try to use your keyboard as much as possible. Use CTRL+SHIFT+ARRO W and SHIFT+ARROW for selecting. Use CTRL+ARROW for navigating when possible.

    Post what you come up with if you have any issues.

    Comment

    • Myriam Kwek

      #3
      Hello, and thanks. Yes I'm using Excel. I know how to write some basic macros using VB code, but I need a macro which transposes cell contents. Similar to the "Paste Special" option in Excel, selecting "Transpose" .

      Right now I've only gotten code to copy a range of cells to another area of the spreadsheet. But I need them to be transposed horizontally.
      Code:
      ' Select the Range To Copy
        ' Range("A6:A10").Select
        ' Selection.Copy
        
         'Put it in Range to Paste
         ' Range("C6:C10").Select
         ' ActiveSheet.Paste

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        Run the macro "Transpose" in the attachment.
        If You want help with the implementation of the macro on Your data, please attach in Bytes a sheet with Your data (or a part of it if the file is to big) and an example how You want the end result.(XLS files must be ZIPPED !)
        Attached Files

        Comment

        • danp129
          Recognized Expert Contributor
          • Jul 2006
          • 323

          #5
          Start recording a macro and record the Paste Special/Transpose so you know how to write it.

          IMO the best way to get started writing Excel macros is by recording your actions and looking at the generated code.

          Comment

          Working...