1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Macro to Copy and Paste From One Cell to Cell Below

Discussion in 'Business Applications' started by lmseaz, Oct 10, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    I selected a cell, and then recorded a macro when I copied the cell, moved down to the cell below it and pasted it. But when I select another cell, and then run the macro, it goes to the initial cells I did when I recorded the macro.

    So is there a macro where I have selected a cell, whatever cell I decide, and then run the macro, and it copies the cell selected and paste it to the cell below the cell that was copied?
     
  2. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    If you take a little time to look at what the recorded macro does, then edit it.
    It is nothing more than a series of instructions.
     
  3. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    Here is the code that was created when I recorded it after selecting cell number F11 which had the words, and copied it and pasted it below to F12....then when I selected another cell with words, and ran the macro, it did not put the words in the cell below the cell I selected, and just put it back to F12....so here is the code, and I have no experience in how to change it, but would very much appreciate what to try thru you:

    Sub Copy_Cell_to_Cell_Under()
    '
    ' Copy_Cell_to_Cell_Under Macro
    '
    '
    Selection.Copy
    Range("F12").Select
    ActiveSheet.Paste
    End Sub
     
  4. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    To ALL, In Case This Helps:

    I researched the concept online, and saw other areas, and one area had a type of line that seemed to be a possibility....I changed the code to try it, and it works perfectly...so here is the updated code if this helps anyone else:

    Sub Copy_Cell_to_Cell_Under()
    '
    ' Copy_Cell_to_Cell_Under Macro
    '
    '
    Selection.Copy
    Range(ActiveCell.Offset(Rowoffset:=1).Address).Select
    ActiveSheet.Paste
    End Sub
     
  5. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    You should start reading on VBA

    try this

    Code:
    Sub Copy_Cell_to_Cell_Under()
    '
    ' Copy_Cell_to_Cell_Under Macro
    '
    '
        Selection.Copy
        Selection.Offset(1, 0).Select
        Selection.PasteSpecial
        
    End Sub
    
     
  6. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    Thanks very much...the code you gave me works when I select one cell and run the macro, it pastes the cell to the cell below....but when I select two or more cells that have different words and run the macro, it only copies the top cell and adds one cell below the top cell based on the top cell....so I need the code that however many cells I select, and run the macro, it copies all the cells I selected and pastes them below the cells I selected....

    Any update to this please?
     
  7. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    Well, that's what you get for not explaining everything, and, the information is still incomplete.
    Which cells will you be selecting, all contiguous cells? alwyas the last cells in the column of maybe half way?
    Guessing is not my strongest :)
     
  8. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    Thanks for you time.

    All I do is select a list of cells in any column...not several columns...just in one column I decide and the list of cells are wherever they are in the column .. not just the top or the bottom...but are a list of cells with words in each cell....make sense?

    So after selecting say 5 cells in one column...run the macro and it puts a copy of the 5 cells below the 5 cells....but the key is not to focus on the number of cells...its just how many I select
     
  9. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    No, I did understand that it's only ONE column but are all the cells together (one range) or is the selection non-contiguous?
     
  10. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    They are all together.....as an example....F4, F5, F6, F7 Not F4, F8, F10
     
  11. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    Code:
    Sub Copy_Cell_to_Cell_Under()
    '
    ' Copy_Cell_to_Cell_Under Macro
    '
    '
    Dim lastRow     As Long
    lastRow = Cells(Rows.Count, Selection.Column).End(xlUp).Row + 1
        Selection.Copy
        Cells(lastRow, Selection.Column).Select
        Selection.PasteSpecial
        
    End Sub
    
    Enjoy it :)
     
  12. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    :)Thanks so so much...it worked perfectly....and even if I select a cell in F1 and G1, it copies and puts them down to F2 and G2....so so great!!

    Now if we wanted to put the cells above the top cell, and not below the lower cell...., what can we adjust please if you know!!:)
     
  13. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,559
    First Name:
    Hans
    You see, you give someone a finger and he takes the whole hand :)
    That will take more code.
    Try the following, it will help you to see how the macro's work, that's how I learned too:
    Record a new macro and do the steps that you want done
    1. Start macro recorder
    2. Give the macro a name
    3. select any number of cells in column F or whatever, right click and press Cut
    4. go to the top row or the first row below the header if there is one and right click on the mouse button and click insert and if asked select move rows down.
    5. stop the macro recorder.

    Then take a look at the code and see if you can figure it out.
    You've got my example to guide you some.

    If you cannot get it to work this way, attach the recorded macro code and I'l try and show you what you have to do, but I suggest you try this, this is simple VBA and anyone can do it and it will make you less dependant on others.
     
  14. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    I will give it a quick try and send the code....

    I have another area re Outlook 2007.....does anyone in this group have that background as I can describe it very quickly...even in this thread....
     
  15. lmseaz

    lmseaz Thread Starter

    Joined:
    Mar 5, 2013
    Messages:
    107
    It only goes back to the row that I recorded going to ...it doesn't just do re whatever cell or cells I am selecting and going above those cells...here is an example of what was recorded..

    So I do think it is something different like you gave me earlier...

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    '
    Selection.Copy
    Range("I19").Select
    ActiveSheet.Paste
    End Sub
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1110382

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice