+ Reply to Thread
Results 1 to 33 of 33

Searching exact 4 values in any cells in same row then change 4th value to 5th value

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

    Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hello All,
    I'm doing manually to update all reports. Is it possible to searching the exact 4 values in same row to the last row within a worksheet, if 4 exact values was found then change the fourth value to 5th values (Please note that the values could be at any cells in the same row)

    First Second Third Fourth
    Let says: if 4 values was found then change "Fourth" to "Fifth"


    Regards,
    tt3
    Last edited by tuongtu3; 10-05-2013 at 07:00 PM. Reason: Solved

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Please attach a sample workbook with enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Note: Please don't attach documents containing confidential data like (address, telephone, ID#s, etc.).


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Sixthsense:
    Thank you for looking. Please take a look at the sample iin attached.

    Regards,
    tt3
    Attached Files Attached Files

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    maybe so
    Please Login or Register  to view this content.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    How to modify the code to do/searching the same in all Worksheets in Workbook?

    Regards,
    tt3
    Last edited by tuongtu3; 09-20-2013 at 02:39 PM.

  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: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    I tried to modify code with below lines to search all ws but doesn't work. Does anyone know how to make it work?

    Please Login or Register  to view this content.
    Regards,
    tt3

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi tt3,

    try this:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Robert,
    I got an error message : Method "Union" of Object '_Global' Failed at below line

    Please Login or Register  to view this content.
    Regards,
    tt3

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Try putting this line...

    Please Login or Register  to view this content.
    ...immediately underneath this line:

    Please Login or Register  to view this content.
    Regards,

    Robert

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Robert,
    It changed value on the first ws then same error message pop up again.

    Updated:
    It works when I change from
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    and now I got error "Object variable or With block variable not set" when I try to get the filename:

    Please Login or Register  to view this content.
    Please help me to fix it.

    Regards,
    tt3






    Regards,
    tt3
    Last edited by tuongtu3; 09-20-2013 at 10:45 PM.

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Setting range variables to nothing clears them so you then cannot use them to return anything. You need to to clear them after you've completely finished with them.

    If the problem persists, try this way where the original code is not touched in any way but run on each sheet via the RunOnAllSheets macro:

    Please Login or Register  to view this content.
    HTH

    Robert
    Last edited by Trebor76; 09-20-2013 at 10:53 PM.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Robert,
    I have no problem with run on all ws but now I'm facing another error when I try to copy the new value and paste to other ws.

    and now I got error "Object variable or With block variable not set" when I try to get the filename:

    [Select Code] copy to clipboard

    If Not rChange Is Nothing Then rChange.Value = "Fifth"
    '''Set rng = Nothing: Set rChange = Nothing put here still same error happen
    rChange.Offset(0, 8).Value = strFileFullName
    rChange.EntireRow.Copy Destination:=Sheets("Sheet9").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)

    Set rng = Nothing: Set rChange = Nothing
    Next wstSheet

    Please help me to fix it.

    Regards,
    tt3
    Updated: I got it to work by add this line:

    Please Login or Register  to view this content.
    Last edited by tuongtu3; 09-21-2013 at 12:34 AM.

  13. #13
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    On Error Resume Next doesn't fix anything - it just stops the error message from appearing. Whatever the underlying problem was, it still remains.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Robert,
    Thank you very much for your clarification.

    I just found out that one of the value was a result of formula of =Vlookup(......), and the code does not recognize the text from the value of formula. Is there anyway to fix this issue?

    Regards,
    tt3

  15. #15
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    the code does not recognize the text from the value of formula
    What is the value? If it's an error like #N/A you could wrap that part of the code with the ISERROR function to ignore it like so:

    Please Login or Register  to view this content.
    Robert

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Robert,
    No, it's not in that way. Let says one of the value "Fourth" is result of "=VLOOKUP(H6,DataReport!A:E,5,FALSE)". You can see text "Fourth" there but code does not recognize the text from the formula. I also attached a sample for more clear.

    Regards,
    tt3
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Ah - you just need to add the LookIn optional argument, i.e. change this line of code...

    Please Login or Register  to view this content.
    ...to this:

    Please Login or Register  to view this content.
    Bear in mind that the formula will be replaced by just text.

    Regards,

    Robert

  18. #18
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi tt
    Re your PM, try it
    Please Login or Register  to view this content.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    The code works but there's another scenario:
    1. How to change 2x of Fourth in same row to Fifth (current code does change 1x Fourth only:
    First-1 Second Third Fourth Fourth
    Regards,
    tt3

  20. #20
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    try
    Please Login or Register  to view this content.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    The code did change 2x of Fourth with "First" , but did not change any Fourth with "First-n"

    Regards,
    tt3

  22. #22
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    What does "First-n"?
    Set an example in a file with all possible input data and the desired result

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    "First-n" is varies of "First-1", "First-2", "First-3" thru "First-9"

    Regatds,
    tt3

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    Please see sample in attached.

    Regards,
    tt3
    Attached Files Attached Files

  25. #25
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi tt,
    try
    Please Login or Register  to view this content.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    The code is really perfect as I expected. Thank you very much for your time and help.

    Regards,
    tt3

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    Sorry I got the error:

    Please Login or Register  to view this content.

  28. #28
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Can you attach file in which the error occurred?

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    I Found out the code does not work bacause of #N/A returned by VLookup Formula. Can you modify code to skip #N/A or how to kill these #N/A. (I tried Find & Replace to kill #N/A, but not sure why does not work ).

    Regards,
    tt3

  30. #30
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi tt,
    try so
    Please Login or Register  to view this content.
    Last edited by nilem; 10-07-2013 at 01:43 PM.

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    I can got filename with old code but now I don't know how to modify to get the file name per your new code. Please help

    Please Login or Register  to view this content.
    Regards,
    tt3

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

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    Hi Nilem,
    I'm trying to modify your code to enter filename at each cell which replaced "Fourth" by "Fifth" at cell AB and copy entire row & paste to Sheet9 but it didn't work. Please help:
    (Text in RED is what I'm trying to add to modify in your code)
    Please Login or Register  to view this content.
    Regards,
    tt3

  33. #33
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Searching exact 4 values in any cells in same row then change 4th value to 5th value

    try
    Please Login or Register  to view this content.

+ 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. Searching for exact phrases
    By joekrebs in forum Excel General
    Replies: 3
    Last Post: 09-12-2011, 03:54 PM
  2. Searching for exact term with date range
    By 97hills in forum Excel General
    Replies: 9
    Last Post: 02-06-2011, 10:00 AM
  3. Searching Range for Exact Match
    By SATEAT in forum Excel General
    Replies: 4
    Last Post: 05-20-2010, 07:14 PM
  4. searching for an exact word
    By antonyjones101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2009, 03:22 PM
  5. [SOLVED] Searching for exact text
    By Josh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2006, 02:10 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