Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Bas
 
Posts: n/a
Default Using relative reference in macro

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?
Reply
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
Copying a work sheet cell reference as relative not absolute? Velson Excel Discussion (Misc queries) 4 January 7th 06 01:46 PM
How do I record a macro with relative cell addresses? Tony IA Excel Discussion (Misc queries) 1 October 28th 05 04:55 PM
Recording new excel macro, relative reference button doesn't show Dano New Users to Excel 3 August 23rd 05 07:36 PM
Relative Macro Help on Keystrokes Neal Zimm Excel Discussion (Misc queries) 9 December 15th 04 12:31 AM
Record Macro Relative does not work? lbbss Excel Discussion (Misc queries) 3 December 13th 04 08:43 PM


All times are GMT +1. The time now is 12:04 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"