+ Reply to Thread
Results 1 to 10 of 10

VBA - Copy cell A if cell AE contains 'YES'

  1. #1
    Registered User
    Join Date
    09-13-2017
    Location
    london
    MS-Off Ver
    2010
    Posts
    9

    VBA - Copy cell A if cell AE contains 'YES'

    I am trying to create a VB Button that will copy the contents of all worksheets' column A of any rows where the contents of Column AE contain 'YES'. Please see attached excel file.

    However, the VB script is pulling back some odd results (e.g. Acrington Stanley) where rows are being copied even though there is no contents in row AE.

    Can anyone help?
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VBA - Copy cell A if cell AE contains 'YES'

    Once you copy the row, what do you want to do with it?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    09-13-2017
    Location
    london
    MS-Off Ver
    2010
    Posts
    9
    Quote Originally Posted by Mumps1 View Post
    Once you copy the row, what do you want to do with it?
    Hi. Have a look at the code already written. I want to copy the contents of the cell in Column A to the Sheet ‘Active Pursuits’. I need to form a list of ALL the clubs that have YES in cell AE but only wish to copy over the contents of column A for each of these.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: VBA - Copy cell A if cell AE contains 'YES'

    Possibly, an if statement would work.,
    for example.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VBA - Copy cell A if cell AE contains 'YES'

    Try:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-13-2017
    Location
    london
    MS-Off Ver
    2010
    Posts
    9

    Re: VBA - Copy cell A if cell AE contains 'YES'

    I get the following error: Run-time error '1004': we can't do that to a merged cell.

    The debug takes me to code line: ws.Range("A4:A" & bottomE).SpecialCells(xlCellTypeVisible).Copy

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: VBA - Copy cell A if cell AE contains 'YES'

    I thought I already answered this,

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VBA - Copy cell A if cell AE contains 'YES'

    The macro doesn't return an error when I run it on the file you posted in Post #1. Click here to download your file and give it a try.
    Last edited by Mumps1; 10-18-2017 at 12:27 PM.

  9. #9
    Registered User
    Join Date
    09-13-2017
    Location
    london
    MS-Off Ver
    2010
    Posts
    9

    Re: VBA - Copy cell A if cell AE contains 'YES'

    It still does not copy across every instance where AE = YES. I am also getting some instances where the AE = empty and the data in column A is being copied. If you insert data into approx 10 rows in column A and Mix column AE with YES and NO, you will see the issue. This is occuring across all worksheets.

    Thanks for all your help.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VBA - Copy cell A if cell AE contains 'YES'

    I added a few Yes's in AE of Football - Premier League and Football - Championship and all worked properly. Have a look at the Pursuits sheet. Click here.

+ 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] Loop copy cell of range to 1 cell, and so on till cell empty
    By countryfan_nt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2017, 02:33 AM
  2. Replies: 13
    Last Post: 11-26-2014, 05:29 PM
  3. Replies: 1
    Last Post: 11-06-2013, 02:56 AM
  4. copy a cell multiple times depending on cell value starting on a specific cell
    By weritadiojomiel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2013, 05:25 AM
  5. copy a specif cell value, find another like that in sheet copy adjacent cell and pate
    By smwaqas89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2013, 10:00 AM
  6. Automatically copy multiple cell VALUES to the cell right below the active cell
    By Sarangsood in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2011, 01:36 AM
  7. Replies: 3
    Last Post: 07-15-2010, 08:49 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