+ Reply to Thread
Results 1 to 13 of 13

Control down with Macro

  1. #1
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153

    Control down with Macro

    I record a macro that copy a portion of a tab to another, but when my data changes the destination get data one above the other. I think it is because instead of sending Control Donw it goes to the cell that I recorded the macro with.

    I probably just need to send Control downkey.

    PHP Code: 
    Range("C22:E22").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Sheets
    .Add
        Range
    ("A2").Select
        ActiveSheet
    .Paste
        Windows
    ("T&S2 5X 2000.xls").Activate
        ActiveWindow
    .ScrollRow 1
        Range
    ("K8:M19").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Range
    ("D2").Select
        Selection
    .PasteSpecial Paste:=xlPasteValuesOperation:=xlNoneSkipBlanks _
            
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteFormatsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteCommentsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Range
    ("A11").Select
        Selection
    .End(xlDown).Select
        Range
    ("A190").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Sheets
    ("TS-3").Select
        Range
    ("C22:E22").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        ActiveSheet
    .Paste
        Range
    ("D190").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Range
    ("K8:M19").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Selection
    .PasteSpecial Paste:=xlPasteValuesOperation:=xlNoneSkipBlanks _
            
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteFormatsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteCommentsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Windows
    ("T&S2 5X 2000.xls").Activate
        Sheets
    ("TS-2").Select
        Range
    ("C22").Select
        Selection
    .End(xlToRight).Select
        Selection
    .End(xlToRight).Select
        Range
    ("C22:E22").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Range
    ("A190").Select
        Selection
    .End(xlDown).Select
        Range
    ("A216").Select
        ActiveSheet
    .Paste
        Range
    ("D216").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Range
    ("G40").Select
        Selection
    .End(xlUp).Select
        Range
    ("K8:M19").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Selection
    .PasteSpecial Paste:=xlPasteValuesOperation:=xlNoneSkipBlanks _
            
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteFormatsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteCommentsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Range
    ("A216").Select
        Selection
    .End(xlDown).Select
        Range
    ("A245").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Sheets
    ("TS-1").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Range
    ("D245").Select
        Selection
    .PasteSpecial Paste:=xlPasteValuesOperation:=xlNoneSkipBlanks _
            
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteFormatsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteCommentsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Range
    ("A245").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Range
    ("C22:E22").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        ActiveSheet
    .Paste
        Windows
    ("T&S2 5X 2000.xls").Activate
        Sheets
    ("T&S Today").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        Selection
    .End(xlDown).Select
        Range
    ("D295").Select
        Selection
    .PasteSpecial Paste:=xlPasteValuesOperation:=xlNoneSkipBlanks _
            
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteFormatsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Selection
    .PasteSpecial Paste:=xlPasteCommentsOperation:=xlNone_
            SkipBlanks
    :=FalseTranspose:=False
        Range
    ("A295").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Range
    ("C22:E22").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Windows
    ("archive.xls").Activate
        ActiveSheet
    .Paste
        Selection
    .End(xlDown).Select
        Range
    ("A308").Select
        Windows
    ("T&S2 5X 2000.xls").Activate
        Windows
    ("archive.xls").Activate
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Range
    ("A294").Select
        Application
    .CutCopyMode False
        ActiveCell
    .FormulaR1C1 "10/6/2007"
        
    Range("A295").Select
    End Sub 
    Last edited by VBA Noob; 10-09-2007 at 01:05 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Is this what your after

    Please Login or Register  to view this content.
    Selects the next cell down from activecell.

    or

    Please Login or Register  to view this content.
    Selects the last used cell in Column A

    You may also found this link helpful

    http://www.rondebruin.nl/copy1.htm

    VBA Noob
    Last edited by VBA Noob; 10-09-2007 at 01:13 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153
    Ok I change my script, so it goes like this.

    Now it move on the same sheet the data, except it will alway's move it to those coordinates and not according to the right size of data.

    PHP Code: 
    Windows("archive.xls").Activate
        Range
    ("H2:L2").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        Range
    ("G2").Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlDown).Select
        Range
    ("A66").Select
        ActiveSheet
    .Paste
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Range
    ("C2").Select
        Selection
    .End(xlToRight).Select
        Selection
    .End(xlToRight).Select
        Selection
    .End(xlToRight).Select
        Range
    ("N2:R2").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlUp).Select
        Range
    ("A141").Select
        ActiveSheet
    .Paste
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlToRight).Select
        Range
    ("T2:X2").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        Range
    ("S2").Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlUp).Select
        Range
    ("A246").Select
        ActiveSheet
    .Paste
        Range
    ("B246").Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlToRight).Select
        Range
    ("Z1:AD1").Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Selection
    .Cut
        Range
    ("X1").Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlToLeft).Select
        Selection
    .End(xlUp).Select
        Selection
    .End(xlDown).Select
        Selection
    .End(xlUp).Select
        Range
    ("A295").Select
        ActiveSheet
    .Paste
        Range
    ("A294").Select
    End Sub 

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if link helps

    http://www.ozgrid.com/VBA/ExcelRanges.htm

    VBA Noob

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why do you have so many duplicate lines in your code & why bother with the Selecting? State clearly what you are copying & where to, your existing code needs a lot of editing.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153
    To BoyUk: when I just paste it there is data mising, it require a special paste.

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    This selects the last used cell in Row 1

    Please Login or Register  to view this content.
    VBA Noob

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This is part of what I mean, the Selection.End(xlToLeft) is duplicated

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153
    After finding the
    Find the last used cell, before a blank in a Column:

    How can I go down 3 cells?

  10. #10
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    I assume you have code to find the last used cell so just do

    last used cell + 3

    VBA Noob

  11. #11
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153

  12. #12
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153
    Even if I tell him to go on the last cell+3 the line just after tell
    PHP Code: 
    Range("K19:L19").Select
        Range
    (SelectionSelection.End(xlUp)).Select
        Range
    (SelectionSelection.End(xlUp)).Select
        Range
    (SelectionSelection.End(xlUp)).Select
        Range
    (SelectionSelection.End(xlUp)).Select
        Range
    (SelectionSelection.End(xlDown)).Select
        Range
    ("K8:L19").Select
        Range
    ("K19").Activate 
    So it will select there to copy. I am stuck.

  13. #13
    Forum Contributor
    Join Date
    05-18-2007
    Posts
    153

    Exclamation

    Quote Originally Posted by royUK
    This is part of what I mean, the Selection.End(xlToLeft) is duplicated

    Please Login or Register  to view this content.
    Ok I know nothing of VB, I just post the macro recorder.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1