+ Reply to Thread
Results 1 to 11 of 11

Copy Paste using loop from one cell to another cell in a different column

  1. #1
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Question Copy Paste using loop from one cell to another cell in a different column

    Hi Gurus,

    I am trying to copy a cell value from Column D to Column C referencing cell "Orders per day" in Column A. Basically a if statement with a loop (IF Column A = "Order Per Day" then Copy Column D value in Column C this should go on until there are no "Orders Per Day" text in Column A). I tired to record a macro with some limited success, but am not able to figure out how to write a better vba with loop. I have attached a copy of my workbook for your inputs.
    HTML Code: 
    Please advise if someone could assist me.

    Regards,
    Ganesh
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Paste using loop from one cell to another cell in a different column

    Try this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Copy Paste using loop from one cell to another cell in a different column

    Thank you Sir, the code worked like it is supposed to. However is it possible to modify this action to happen only once every month when there is a change in date. Say current month in Cell D10 changes from March to April.

    Your advice would help me greatly.

    Once again thank you Jerry.

    Best regards,
    Ganesh

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Paste using loop from one cell to another cell in a different column

    Your question doesn't match the original ask nor does it seem to match the sample workbook. Please upload an example that exactly demonstrates the before/after that you are seeking.

  5. #5
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Question Re: Copy Paste using loop from one cell to another cell in a different column

    Sorry about the inconvenience. I am trying to copy a cell value from Column D16 to Column C16 referencing cell "Orders per day" in Column A. This action should happen only when the month in Cell D10 changes. If the month in cell D10 does not change (I update the file multiple times during the month) then the data in Cell C16 should remain unchanged. Now there are 10 sheets in the workbook, this VBA should only run on 4 sheets . I have included 2 sheets on which the vba needs to run.

    I am attaching a workbook with comments on the cells that need to be changed. I hope this example helps you in understanding what I am trying to accomplish. I am a novice when it comes to writing vba.

    Thanks

    Ganesh
    Attached Files Attached Files

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Paste using loop from one cell to another cell in a different column

    Hmm, looking at your new sheet, I see three spots you circled in red, but I see no difference in those and the additional spots further down the sheet you did not circle.

    I do not see the logic for updating those rows and not the other rows further down.

  7. #7
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Copy Paste using loop from one cell to another cell in a different column

    You got me on that, I circled it only for reference. The sheets need to be updated all through to the end.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Paste using loop from one cell to another cell in a different column

    Then I fail to understand how the macro already provided fails to serve. When run on any sheet it will update every row that has Orders per day in column A. Is it not doing that for you?

  9. #9
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Question Re: Copy Paste using loop from one cell to another cell in a different column

    Hi Jerry, the macros you provided works fine, however I would like the vba to trigger only when the information in (current month) cell D10 changes. Cell D10 represent month and if based of a formula. It is populated using this formula "DATE(YEAR(TODAY()),MONTH(TODAY()),1)".

    [ATTACH][/ATTACH]

    Hope this information helps.

    thanks
    ganesh
    Attached Images Attached Images
    Last edited by Ganeshgopinath; 04-05-2016 at 11:53 AM.

  10. #10
    Registered User
    Join Date
    11-13-2011
    Location
    ND, USA
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Copy Paste using loop from one cell to another cell in a different column

    Jerry, I came up with this macro for triggerring the VBA once date changes (included your part of the vba too), and it looks like it is working as I manually change the D10 cell to test it. Not sure if it is the right, will only know as I test it in the actual report. Please advise if it makes sense from your point of view.

    HTML Code: 
    Thanks for helping.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy Paste using loop from one cell to another cell in a different column

    Glad to be of help. If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] Copy Cell From One Cell and Paste to next blank cell, Loop until last row/column
    By Beginner Level in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2020, 02:38 AM
  2. [SOLVED] Loop through column check for colored cell and copy that cell to cells below it.
    By RENCE19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 04:51 AM
  3. [SOLVED] Copy and Paste cell value in for loop
    By chouston in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 03-16-2013, 09:23 AM
  4. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  5. Loop to find a cell, then copy offset paste
    By mr.alexander in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-29-2013, 08:48 AM
  6. Loop to copy and paste cell values
    By prontrad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2011, 09:52 AM
  7. loop and copy adjucent cell and paste somewhere else
    By gill389 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2010, 01:20 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