Using relative reference in macro

B

Bas

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("Input").Select
Selection.Copy
Sheets("Arr Dep ").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("W34").Select
ActiveCell.Offset(0, -2).Range("A1:C1").Select
ActiveCell.Activate
Application.CutCopyMode = False
Selection.Cut Destination:=ActiveCell.Offset(0, 2).Range("A1:C1")
ActiveCell.Offset(0, 2).Range("A1:C1").Select
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveCell.Offset(0, -9).Range("A1:E1").Select
ActiveCell.Offset(0, -5).Range("A1").Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -2).Range("A1:E1")
ActiveCell.Offset(0, -2).Range("A1:E1").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("A1:B1").Select
ActiveCell.Offset(0, -5).Range("A1").Activate
Selection.Cut Destination:=ActiveCell.Offset(0, 3).Range("A1:B1")
ActiveCell.Offset(0, 1).Range("A1:B1").Select
ActiveCell.Offset(0, 2).Range("A1").Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -2).Range("A1:B1")
ActiveCell.Offset(0, -4).Range("A1").Select
Selection.Cut Destination:=ActiveCell.Offset(0, 4).Range("A1")
ActiveCell.Offset(0, 4).Range("A1").Select
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveCell.Offset(0, -10).Range("A1:F1").Select
ActiveCell.Offset(0, -5).Range("A1").Activate
Selection.Cut Destination:=ActiveCell.Offset(0, -3).Range("A1:F1")
ActiveCell.Offset(0, -8).Range("A1").Select
End Sub

Can anybody help please?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top