Developing Matt

My Technical Journal

Flip Horizontal/Vertical in Excel

with 3 comments

I’ve had to write this a couple of times, so I’m posting it here so that I can have it for the next time, assuming I’ll remember it’s here.  It’s just a vba script for excel to pivot your list of horizontal or vertical items the opposite way.  Nothing too fancy, but it will save you 20 minutes of writing it out yourself.  I’m sure there’s a way to do this in Excel, but I haven’t found it.

 Public Sub flipDataHorizontal()
Range(“a1”).Select
Dim i As Integer
For i = 1 To 200
ActiveCell.Offset(i, 0) = ActiveCell.Offset(0, i)
ActiveCell.Offset(i, 0).NumberFormat = ActiveCell.Offset(0, i).NumberFormat
Next
End Sub

Public Sub makeColumns()
Range(“a1”).Select
Dim i As Integer
For i = 1 To 200
ActiveCell.Offset(0, i + 1) = ActiveCell.Offset(i, 0)
ActiveCell.Offset(0, i + 1).NumberFormat = ActiveCell.Offset(i, 0).NumberFormat
Next
Columns(“a”).Delete
End Sub

Advertisements

Written by matt

November 29, 2007 at 9:36 am

Posted in VBA

3 Responses

Subscribe to comments with RSS.

  1. Select the horizontal cells and then while hovering over the selection right-click with your mouse and select “Copy” then select the uppermost cell of where you would like to paste the selection vertically and right-click again, now select “Paste Special…” then check “transpose” then click “OK”.

    Zentac

    May 7, 2009 at 8:04 am

    • This method worked very well when I have only one row of data (5 columns). Thanks! But when I tried on multiple rows it didn’t work. Any suggestions?

      Songqian

      May 17, 2009 at 6:30 pm

  2. God love ya zentak. Thanks. MUCH MUCH EASIER.

    matt

    May 7, 2009 at 8:07 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: