+ Reply to Thread
Results 1 to 12 of 12

Help with VBA/Macro to copy and paste values based on criteria

  1. #1
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Help with VBA/Macro to copy and paste values based on criteria

    Hi,

    I would like some help with creating a macro which copy and paste values over the formulas based on a criteria please.

    The aim of the macro is to copy and paste values over the formulas in Column P and U in the Provider Detail tab, if the value in column L is less than the value in C4 within the Activity and Finance tab. The macro must repeat the loop until it has reached the bottom of the table.

    The attached is an example of the layout of the spreadsheet which requires the macro.

    Would anyone be able to assist as my knowledge of vba/macros is very limited.

    Thanks in advance for your help
    Bhaz
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor than_gold's Avatar
    Join Date
    10-17-2017
    Location
    Coimbatore India
    MS-Off Ver
    Office 365
    Posts
    646

    Re: Help with VBA/Macro to copy and paste values based on criteria

    What should do if col L value > C4?
    Regards,
    Thangavel D

    Appreciate the help? CLICK *

  3. #3
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with VBA/Macro to copy and paste values based on criteria

    Quote Originally Posted by than_gold View Post
    What should do if col L value > C4?

    the formula should remain if col L value >= C4

  4. #4
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with VBA/Macro to copy and paste values based on criteria

    i have tried writing the following vba but am getting an compile error message "end with without with".

    Please Login or Register  to view this content.
    could you please advise on how to fix it?

    thanks in advance for your help

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with VBA/Macro to copy and paste values based on criteria

    Hi !

    You failed with the order of your End With and Next

  6. #6
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7
    Quote Originally Posted by Marc L View Post
    Hi !

    You failed with the order of your End With and Next
    So should it be;

    next
    End with

    ?

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with VBA/Macro to copy and paste values based on criteria


    Yes !

    Classic issue with a not or bad indented code …

  8. #8
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with VBA/Macro to copy and paste values based on criteria

    could you please fix this for me as my vba knowledge is limited and I dont understand what I'm doing wrong;

    Please Login or Register  to view this content.
    Thanks

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with VBA/Macro to copy and paste values based on criteria


    Seems code has logic issues of using object variables but for criteria better as efficient is to use a filter or an advanced filter
    as you can yet operate manually so with the Macro Recorder you can get your own free base of code …

  10. #10
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with VBA/Macro to copy and paste values based on criteria

    Quote Originally Posted by Marc L View Post

    Seems code has logic issues of using object variables but for criteria better as efficient is to use a filter or an advanced filter
    as you can yet operate manually so with the Macro Recorder you can get your own free base of code …
    I dont understand the logic for writing the code, could you please help me

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with VBA/Macro to copy and paste values based on criteria


    As any beginner can do, activate the Macro Recorder, apply a filter then copy, …
    In case of an optimization need, post here the generated code explaining what you need to be improved.

  12. #12
    Registered User
    Join Date
    05-02-2018
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Help with VBA/Macro to copy and paste values based on criteria

    I have amended the file slightly by adding a new column which checks if the value in column L is less than the value in C4 within the Activity and Finance tab.

    The macro below filters based on the value in column W = "yes" and then copy paste values in P2. I would like help with amending the macro please to continue copy paste values for all the cells in column p where the filter is applied.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Bhaz; 05-04-2018 at 10:45 AM.

+ 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. Copy Paste Macro Based on Criteria
    By Dan_B in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-08-2017, 03:32 AM
  2. Copy paste Values based on criteria
    By toci in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 04-15-2016, 08:29 AM
  3. Alternative to copy and paste values based on criteria
    By krishns in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-10-2015, 12:07 PM
  4. Replies: 1
    Last Post: 10-05-2014, 12:28 PM
  5. [SOLVED] copy Tabs, based on two criteria in column J and paste values
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-13-2013, 03:46 PM
  6. [SOLVED] Macro to Copy Data and Paste Values Based on cell criteria
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-16-2012, 06:51 PM
  7. copy and paste values based on a criteria
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 11-15-2008, 11:35 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