LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Last Column to first Column

Hi Emoe

You are welcome.

Try this specialmade macro for you. 8-)
Now you can reserve x rows/ y columns.

Option Explicit

'Sheet2 Startcell *****
Const StartCellSh2 As String = "B3"

'----------------------------------------------------------
' Procedure : Sheet1ToSheet2FlipColumns
' Date : 20060614
' Author : Joergen Bondesen
' Modifyed by :
' Purpose : Copy Sheet 1 to Sheet 2 and flip columns
' on sheet 2
' Note : Formula will be converted to Fixed value.
' Fill in StartCellSh2 *****
'----------------------------------------------------------
'
Sub Sheet1ToSheet2FlipColumns()
Dim x As Long
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim cell As Range

Application.ScreenUpdating = False

Set WS1 = Worksheets("Sheet1") 'From
Set WS2 = Worksheets("Sheet2") 'To

With WS2
.Cells.Clear

WS1.UsedRange.Copy _
Destination:=.Range(StartCellSh2)

'// Sortrow insert
.Rows(.Range(StartCellSh2).Row).Insert Shift:=xlDown

For x = .Range(StartCellSh2).Column To _
.UsedRange.Columns.Count + .Range(StartCellSh2) _
.Column - 1

.Cells(.Range(StartCellSh2).Row, x).Value = _
.Cells(.Range(StartCellSh2).Row, x).Column
Next x

' '// Formula 2 Fixec value
' For Each cell In .Cells.SpecialCells _
' (xlCellTypeFormulas, 23)
'
' cell.Value = cell.Value
' Next cell

'// Sort
.UsedRange.Sort _
Key1:=.Range(StartCellSh2), _
Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal

'// Sortrow delete
.Rows(.Range(StartCellSh2).Row).Delete Shift:=xlUp

End With

Set WS1 = Nothing
Set WS2 = Nothing
End Sub


--
Med venlig hilsen
Jørgen Bondesen


"EMoe" wrote in message
...

Thanks a bunch Joergen!
Sorry it took me so long to respond.

The code works fine.
I was trying to figure out though, when it places the values onto sheet
2, where in the code can I tell it to start from the second column,
instead of the first. I would like to reserve the first column for
names.

But All In All; the code is what I am looking for.

Thanks again,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=550815



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
divide column(x) by column(y) to give column(x/y) in excel? James New Users to Excel 2 April 24th 23 11:46 AM
Referencing date column A & time column B to get info from column TVGuy29 Excel Discussion (Misc queries) 1 January 24th 08 09:50 PM
Return text in Column A if Column B and Column K match jeannie v Excel Worksheet Functions 4 December 13th 07 07:36 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
formula : =(column A)+(column B)-(column C). Why won't it work? Kristin Drover Excel Discussion (Misc queries) 3 October 18th 06 08:48 PM


All times are GMT +1. The time now is 04:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"