+ Reply to Thread
Results 1 to 8 of 8

Macro with If statements to find word and then copy

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Macro with If statements to find word and then copy

    I need a macro to look for the first NUMBER in column C. The number will be ALONE in a cell always. When it finds this number I want it to look 2 cells to the left and if the word 'CON' appears then copy the number and paste it on the first unused row in Sheet2 column F BUT only if in column A in the row ABOVE where the first number is found equals what is contained in cell C1. If the word 'PON' appears instead of 'CON then copy the number and paste it on the first unused row in Sheet2 column H BUT only if in column A in the row ABOVE where the number is found equals what is contained in cell C1. If the word 'TRIP' appears instead of the other two words then copy the number and paste it on the first unused row in Sheet2 column X BUT only if in column A in the row ABOVE where the number is found equals what is contained in cell C1.

    After it finds the first number it should loop and find the 2nd number and apply the same criteria above except that instead of ensuring cell C1 = the cell Ax where X is the row above where the 2nd number is found, it looks at Ay where y is 2 rows above where the 2nd number is found. So then when it looks for the 3rd number it'll look for the 3rd row above where the 3rd number is found etc etc.

    I know this is possible somehow. Thanks in advance!
    Last edited by ScabbyDog; 01-10-2016 at 04:03 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro with If statements to find word and then copy

    Sample.xlsm

    Sample attached.

  3. #3
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro with If statements to find word and then copy

    Hopefully I've worded my question so you guys can understand. If not, just let me know and I'll try and be clearer!

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro with If statements to find word and then copy

    Sample.xlsm

    I've updated the sample workbook. Sheet2 in the workbook attached now contains the results I expect from the macro running.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro with If statements to find word and then copy

    The below would solve the first part of my query if someone can help me out with the bits in bold
    Please Login or Register  to view this content.
    Last edited by ScabbyDog; 01-10-2016 at 06:49 AM.

  6. #6
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Macro with If statements to find word and then copy

    Hi ScabbyDog,
    I don't know VBA code but I use Formula so please try it and sorry if that's not what you want.
    Hope expert will be helping you after this
    Regards,
    tt3
    Attached Files Attached Files

  7. #7
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Macro with If statements to find word and then copy

    Try this.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by skywriter; 01-11-2016 at 04:19 AM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  8. #8
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Macro with If statements to find word and then copy

    @Skywriter - Super stuff. Solves my query perfectly. Can't praise you enough!

+ 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] Excel VBA Macro - Find Word and Select that Column to Column D and copy
    By MsBBStacker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2015, 12:04 AM
  2. [SOLVED] Help with macro to find a specific word and replace the entire cell with the return word.
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-24-2015, 09:40 PM
  3. Excel Macro for Find/Copy Keywords from Word Files to Excel
    By akalyoncu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2014, 05:22 PM
  4. [SOLVED] Macro to find specific word in cell and then copy and paste the adjacent cell upwards
    By raytej82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2014, 05:33 PM
  5. Replies: 8
    Last Post: 11-04-2013, 02:34 PM
  6. [SOLVED] Excel macro- Find replace an itallic font word with a regular word?
    By thisisaboutwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 01:48 PM
  7. Need help with Excel-to-Word find and replace macro based on word filename
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 12:48 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