close

I want to copy and paste a range from 1 column to 1 row (transpose). This is
no problem. Then i want to shift some of the cells to their final location,
which is in the same row. I want to do this automatically, using a macro.
But when I play the macro, everything works ok, except that the shifted
cells aren't in their location they should be! The relative reference button
is switched on, but it seems that it refers to the wrong cell.

I'm not really familiair with VBA codes, but this is the macro i've recorded:

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 23-03-2006
'

'
Sheets(quot;Inputquot;).Select
Selection.Copy
Sheets(quot;Arr Dep quot;).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
True, Transpose:=True
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
Range(quot;W34quot;).Select
ActiveCell.Offset(0, -2).Range(quot;A1:C1quot;).Select
ActiveCell.Activate
Application.CutCopyMode = False
Selection.Cut Destination:=ActiveCell.Offset(0, 2).Range(quot;A1:C1quot;)
ActiveCell.Offset(0, 2).Range(quot;A1:C1quot;).Select
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveCell.Offset(0, -9).Range(quot;A1:E1quot;).Select
ActiveCell.Offset(0, -5).Range(quot;A1quot;).Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -2).Range(quot;A1:E1quot;)
ActiveCell.Offset(0, -2).Range(quot;A1:E1quot;).Select
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveCell.Offset(0, -6).Range(quot;A1:B1quot;).Select
ActiveCell.Offset(0, -5).Range(quot;A1quot;).Activate
Selection.Cut Destination:=ActiveCell.Offset(0, 3).Range(quot;A1:B1quot;)
ActiveCell.Offset(0, 1).Range(quot;A1:B1quot;).Select
ActiveCell.Offset(0, 2).Range(quot;A1quot;).Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -2).Range(quot;A1:B1quot;)
ActiveCell.Offset(0, -4).Range(quot;A1quot;).Select
Selection.Cut Destination:=ActiveCell.Offset(0, 4).Range(quot;A1quot;)
ActiveCell.Offset(0, 4).Range(quot;A1quot;).Select
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveCell.Offset(0, -10).Range(quot;A1:F1quot;).Select
ActiveCell.Offset(0, -5).Range(quot;A1quot;).Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -3).Range(quot;A1:F1quot;)
ActiveCell.Offset(0, -8).Range(quot;A1quot;).Select
End Sub

Can anybody help please?

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()