1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Macro column data into rows

Discussion in 'Business Applications' started by excelyell, Nov 8, 2011.

Thread Status:
Not open for further replies.
  1. excelyell

    excelyell Thread Starter

    Nov 8, 2011
    Hi - i am trying to write a macro to move data from some rows to columns, but its not a straightforward transpose. Attached is the example

    and if there are any blanks not to transpose those.


    Attached Files:

  2. Rollin_Again


    Sep 4, 2003
    Select your range of data to evaluate (in your attached example you would select C3:N12) and then run the macro below. The macro will create a new sheet with the transposed data.

    Sub Transpose()
    oldSheet = ActiveSheet.Name
    Worksheets.Add().Name = "NewSheet"
    For Each vcell In Selection.Cells
    If vcell.Value <> "" Then
    vRow = Sheets("NewSheet").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    Sheets("NewSheet").Range("A" & vRow).Value = Range("A" & vcell.Row).Value
    Sheets("NewSheet").Range("B" & vRow).Value = Range("B" & vcell.Row).Value
    Sheets("NewSheet").Range("C" & vRow).Value = Cells(2, vcell.Column).Value
    Sheets("NewSheet").Range("D" & vRow).Value = vcell
    End If
    Next vcell
    End Sub
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1026000

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice