+ Reply to Thread
Results 1 to 4 of 4

VBA to forward or backward copy and paste function

Hybrid View

  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    VBA to forward or backward copy and paste function

    I have spreadsheet with data in A1:Z5 and I would like to have cut and paste 3 joint columns from within A1:Z5 into A10:C14 which is the fixed location for the chosen data. The difficulty is that I need a Macro that can forward or backward the 3 joint columns from A1:Z5 to be pasted to A10:C14.

    Example I start with data in A1:C5 and have them pasted in A1:C14. The next step I want to "forward" and the chosen 3 column, B1:D5 will be pasted in A10:C14. The next forward VBA will paste C1:E5 in A10:C14. If I do a "backward" from here , then B1:D5 will be pasted in A10:C14.

    Appreciate help in the VBA coding as my simple record macro can only help me do the first step.

     Range("C1:E5").Select
        Selection.Copy
        Range("A10").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    Last edited by outlook888; 12-10-2013 at 12:05 PM.

  2. #2
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Buffalo, NY
    MS-Off Ver
    Office 365
    Posts
    314

    Re: VBA to forward or backward copy and paste function

    It's probably a little bit more complex than you imagine, Outlook.

    At the heart of your request is the following:
    * Intercept any Left and Right Arrow keys (that's what you mean by Forward and Back, right?) and translate them into movements of a multi-cell block, and then place the contents of the newly selected block into a specified area.

    If that is NOT a correct interpretation of what you are asking for, please let us know, as soon as possible.

    If that's the case, then there are more questions.

    Even though the block may be 3 columns wide and 5 columns high, what happens if you type an Up- or Down-Arrow? There are several possibilities:

    1) De-select the block, and simply move to the cell which is one up or down from the top-left hand corner (or top right, or bottom left, or bottom right)

    2) Keep the block selected, and select the block that includes a cell outside your data area

    3) If you move outside the special zone, and then move back, should the block automatically be selected again? Based on which cell?

    As you can see - the possibilities multiply very fast.

    While I wait to hear from you again, I'll see what I can put together

    HTH

    Tony

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to forward or backward copy and paste function

    In a helper Column for example AA. From AA1 sequence numbers (ie 1, 2, 3, 4) on down the column. Then maybe:

    Sub outlook888zz()
    Dim x As Long
    x = Range("AA1").Value
    Range(Cells(1, x), Cells(1, x).Offset(5, 2)).Copy Range("A10")
    Range("AA1").Delete xlUp
    End Sub

  4. #4
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA to forward or backward copy and paste function

    The interpretation is correct except the VBA is not trigger by just clicking on the left and right arrow.

    The forward and backward could be via CONTROL + <-- or --> or Control + 1 or 2 so up or down arrow will not affect the VBA.
    Or I can use my mouse to click on two created button for the forward and backward action.

    When I doing the forward and backward function, I will not be doing anything else on the spreadsheet. The sole purpose is just to copy and paste different blocks into the specific area. I will be always in the special zone of A1:Z5 and selecting different blocks to be pasted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Looping backward or forward? "Step -" construct. VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2012, 11:03 AM
  2. Copy / Paste Function
    By seanrigby in forum Excel General
    Replies: 3
    Last Post: 01-12-2012, 12:59 PM
  3. Tab function sets me forward one page instead of one row
    By acote@genetec.com in forum Excel General
    Replies: 2
    Last Post: 01-02-2006, 07:20 PM
  4. [SOLVED] Dataform - Forward/Backward Control
    By Jim May in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-04-2005, 08:05 AM
  5. Backward and Forward Compatibility
    By Cathy in Florida in forum Excel General
    Replies: 3
    Last Post: 03-01-2005, 12:06 PM

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