Consulting

Results 1 to 12 of 12

Thread: How to post predefined cell value to active cell

  1. #1
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    5
    Location

    How to post predefined cell value to active cell

    I am a newbie in VBA Excel.
    Let's say, I have to take the value of cell A1 and paste it to the active cell in the SAME column.
    So, copy cell A1 with value 123 to the active cell A10.
    Sounds easy? Please help.

  2. #2
    without VBA, you can just copy/paste the value from A1 to A10.
    or add a formula in A10:

    =A1

    with VBA, just Record a Macro.

  3. #3
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    5
    Location
    Quote Originally Posted by levvosk View Post
    I am a newbie in VBA Excel.
    Let's say, I have to take the value of cell A1 and paste it to the active cell in the SAME column.
    So, copy cell A1 with value 123 to the active cell A10.
    Sounds easy? Please help.
    I maybe did not explain the task very well. I am looking for copy/paste automation. I need to paste the value from the top row cell to the same column cell below by activating this cell and hitting the shortcut key. In my mind, it should be a macro with custom VBA code inside.
    Thank you in advance.

  4. #4
    that's what i said,
    Record a macro.
    copy and paste the cells.
    Save the macro.
    if you go to VBA you will see that it created a Public sub with VBA code in it.
    you only need to Edit the macro to Always copy from the Top cell.

  5. #5
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    5
    Location
    "Edit the macro to Always copy from the Top cell" - it's my problem. I need to have the same logic for all 100 other columns.

  6. #6
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,033
    Location
    Sub Macro1()
    ' Copy and Paste row
    'Range("A1:CW1").Copy
        Range("A10").Paste
    End Sub
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    VBAX Expert
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    688
    Location
    For something like this you may not even need copy/ paste

    Sub MoveVal()    
        Range("A10").Value = Range("A1").Value
    End Sub
    If things don't change they stay the same
    Quite often there is a picnic problem (problem in chair not in computer)
    "We were not told it was impossible, so we did it."

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,302
    Location
    "Edit the macro to Always copy from the Top cell" - it's my problem. I need to have the same logic for all 100 other columns.

    That's why it's important to provide all information and maybe even a sample workbook


    Option Explicit
    
    Sub Something()
        Range(Range("A1"), Range("A1").End(xlToRight)).Copy Cells(ActiveCell.Row, 1)
    End Sub
    Last edited by Paul_Hossler; 01-27-2022 at 06:36 AM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    5
    Location
    Hi Paul,

    It's worked! The thing is it's copying the entire top row to the active row/cells. I just looking for a copy one cell at a time from the top row cell.
    Thank you!

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,302
    Location
    Guess I misunderstood:

    I need to have the same logic for all 100 other columns.
    Option Explicit
    
    
    Sub Something1()
        Cells(1, ActiveCell.Column).Copy ActiveCell
    End Sub
    If that is still not it, then you'll have to come up a very detailed example workbook
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  11. #11
    VBAX Newbie
    Joined
    Jan 2022
    Posts
    5
    Location
    You got it! Very elegant!

    THANK YOU VERY MUCH! I REALLY APPRECIATE IT!

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Posts
    8,302
    Location
    Glad it works

    You can mark it [SOLVED] using #3 in my signature
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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