Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Select Case SourceColumn
Case Is = 1 DestinationColumn = 5 Case Is = 2 DestinationColumn = 3 Case Is = 3 DestinationColumn = 11 Case Is = 4 DestinationColumn = 1 Case Is = 5 DestinationColumn = 6 Case Is = 6 DestinationColumn = 8 Case Is = 7 DestinationColumn = 7 End Select An alternate to (that is, replacement for) the above section of your code that the OP may want to consider using is this single line statement... DestinationColumn = Choose(SourceColumn, 5, 3, 11, 1, 6, 8, 7) -- Rick (MVP - Excel) "Mike H" wrote in message ... Hi, This is Sh1 worksheet code and assumes Sh2 is called Sheet2 Sub MoveIt() Dim SourceColumn As Long Dim DestinationColumn As Long Dim LastRow As Long For SourceColumn = 1 To 7 LastRow = Cells(Rows.Count, SourceColumn).End(xlUp).Row Range(Cells(2, SourceColumn), Cells(LastRow, SourceColumn)).Copy Select Case SourceColumn Case Is = 1 DestinationColumn = 5 Case Is = 2 DestinationColumn = 3 Case Is = 3 DestinationColumn = 11 Case Is = 4 DestinationColumn = 1 Case Is = 5 DestinationColumn = 6 Case Is = 6 DestinationColumn = 8 Case Is = 7 DestinationColumn = 7 End Select LastRow = Sheets("Sheet2").Cells(Rows.Count, DestinationColumn).End(xlUp).Row Sheets("Sheet2").Cells(LastRow + 1, DestinationColumn).PasteSpecial Next Mike "John Pierce" wrote: Sh1 Sh2 A E B C C K D A E F F H G G |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy rows from one Data sheet to another sheet based on cell conte | Excel Discussion (Misc queries) | |||
copy data of two cells from Sheet 2 into one cell in Sheet 1 | Excel Worksheet Functions | |||
How can i copy data from a tabbed working sheet to a summary sheet | Excel Discussion (Misc queries) | |||
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 | Excel Worksheet Functions | |||
Copy data from sheet 1 to sheet 2 based on day/date | Excel Programming |