+ Reply to Thread
Results 1 to 8 of 8

VBA code to copy and paste to next cell

  1. #1
    Registered User
    Join Date
    05-26-2015
    Location
    Australia
    MS-Off Ver
    MS Office 13
    Posts
    16

    VBA code to copy and paste to next cell

    I am trying to write a simple macro in excel to do some calculations and copy and paste the sum from cell O2 to cell T2. Do some more calculations and copy and paste the sum from cell O2 to cell T3 (next cell) and continue the process till it's finished. I am not sure how I can get code to paste the value in the next cell (T3). Here are the codes I have done so far. Can you please help? Thank you.

    Please Login or Register  to view this content.
    Last edited by davesexcel; 03-14-2021 at 07:16 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code to copy and paste to next cell

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    05-26-2015
    Location
    Australia
    MS-Off Ver
    MS Office 13
    Posts
    16

    Re: VBA code to copy and paste to next cell

    Hello AlphaFrog,

    Thank you for your prompt reply. These codes does the job, but not all of it. On my spreadsheet the cell "O1" is the sum of "O2:O1803". I would like the macro to copy the value of this sum in to cell "T2". And the next new sum in to cell "T3" and so on till end. Is this possible to include in this code? If so, how would do it? Thank you for your help.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code to copy and paste to next cell

    In the code, Change the O2 to O1

  5. #5
    Registered User
    Join Date
    05-26-2015
    Location
    Australia
    MS-Off Ver
    MS Office 13
    Posts
    16

    Re: VBA code to copy and paste to next cell

    Great, Thank you AlphaFrog.

  6. #6
    Registered User
    Join Date
    05-26-2015
    Location
    Australia
    MS-Off Ver
    MS Office 13
    Posts
    16

    Re: VBA code to copy and paste to next cell

    Hello AlphaFrog,

    I would like to add the "If" statement to this code. See below codes. What am I doing wrong?

    Please Login or Register  to view this content.
    Thank you for your help.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code to copy and paste to next cell

    Change the Else to End If

  8. #8
    Registered User
    Join Date
    05-26-2015
    Location
    Australia
    MS-Off Ver
    MS Office 13
    Posts
    16

    Re: VBA code to copy and paste to next cell

    Thank you AlphaFrog. It works like a magic.

+ 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. [SOLVED] VBA code for copy paste data to active cell
    By keshavtale in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2020, 02:58 AM
  2. Excel VBA code to copy a Range and paste it within a cell
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2014, 02:40 AM
  3. Code to copy and paste cell value from last used row to new row not working
    By figbash in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2014, 02:02 PM
  4. VBA Code to copy cell range and paste to certain sheet
    By goguneon in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-03-2013, 08:35 AM
  5. VBA code to copy cell value and paste in different sheet
    By mubashar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 01:26 AM
  6. Code to Copy, Divide Cell Content and Paste
    By AntiPivotTable in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2013, 07:59 PM
  7. [SOLVED] Code to search a cell, copy and paste
    By MDEN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2012, 05:19 AM

Tags for this Thread

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