+ Reply to Thread
Results 1 to 18 of 18

Find specific text in a cell and update values in other cell

  1. #1
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Find specific text in a cell and update values in other cell

    Hi,

    I have been trying to build on a code where I want my code to perform these actions:

    a. Go to cell C2, look for keywords like- Cloud, Data Center, Internet
    b. Once any of these keywords are found, go to cell D2 and update as "Port Open"
    c. o to next cell C3, look for keywords like "F5, Load" and update cell D3 as "F5"


    This same action needs to be performed for all the rows in the sheet and data keeps changing (as shown in the keywords sheet for Category and Sub-Category)

    Attached is the sample file with 2 sheets:
    1. Raw Data
    2. Keywords

    Any help here will be highly appreciated.
    Attached Files Attached Files
    Last edited by ruchikasharma9727; 08-17-2020 at 08:04 AM. Reason: Incorrect file attached earlier

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Find specific text in a cell and update values in other cell

    if you move from cell to cell and the search data keeps changing every time or for every row, i'm pretty sure there is nothing in the interface (eg - buttons you can click, formulas you can write) that will be able to handle this. and if you need to write code to do it, I don't think visual basic is good enough to make that simple. there are a things available that you can maybe do though. you can use static array and just throw the values in during the declaration section before the routine even starts running. you can also hard code everything during the looping process.

    the other things you might be able to do, which just came to mind, is list all of your "key" data (e.g. - the date you want to search by, for each row) in a separate sheet, line by line, and then use code to loop through that sheet, line by line, capture the key data used for the search criteria and ask the code to look at the corresponding row on the main sheet to find the data you want. then obviously, update the data you're referring to.

    per my second though, there also might be an internal function in excel you can use to look up data and pick out what you need. but I'm 50% confident that your requirements are too complex for excel's resources to handle it.

  3. #3
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    Hi ruchikasharma9727,

    Try the below code, it will paste the data in column G just for you to see & compare ... I tried it & it gave me about 50% matching output but you get the idea. This is one way to do it & you can add more key words ...

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  4. #4
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Thank you so much. This really works.

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Find specific text in a cell and update values in other cell

    please mark this as solved then.
    Attached Images Attached Images

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    Glad I could help & thanks for the reps

  7. #7
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Hi nankw83,

    One more question around the same problem.
    I'm able to get the results in Col. V basis Col. C observation. The non-matching results show as N/A.
    Now, I'm trying to do: all the N/A entries in Col. V should go through the same code again but this time in Col. D to get the results.
    I'm trying to use Do While loop but it seems to be not working. Any help please. Here is my code I'm writing in a new module:

    HTML Code: 

  8. #8
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    Hi ... Just to clarify, the code now reads column D then loop through each row to see a matching then paste the output in column V. What you want to do is once this process is completed, repeat the process but instead of column D as a source take column C as source & only consider entries with N/A in column V & then update the results in column V again ?

    I'm a bit confused between column D & C as the code reads column D & you said column C

  9. #9
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Sorry for the confusion. But it is vice versa.
    My code was earlier taking Col. C as source. I now want :

    Once the process is completed (with Col. C), repeat the process but instead of column C as a source take column D as source & only consider entries with N/A in column V & then update the results in column V again.

    The code which I've shared above is what I'm trying to write to meet this requirement.

  10. #10
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    Try below code, I have adjusted the "N/A" section to search again in next column before putting "N/A" ... I have highlighted the changes in code in Red

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Hey, this works

    Could you please make me understand few things here for my knowledge:

    a. a = ws.Range("C2", ws.Range("C" & Rows.Count).End(3)).Resize(, 2)- Why have we used End(3)? I usually use xlUp, xlDown etc.. and what is Resize (,2) going to do?

    b.
    HTML Code: 
    Please help me understand this part.

  12. #12
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    .End(3) and .End(xlUp) basically do the same thing, you can use numbers from 1 to 4 as you can see below

    1 = xltoLeft
    2 = xltoRight
    3 = xlUp
    4 = xlDown

    .Resize(,2) basically to extend my range of data in array 'a' for two columns instead of 1 i.e. to include data from columns C & D in my 'a' array

    Regarding the last section, instead of directly putting "N/A" like before, I change the value of column C that is not found with the value from column D then change the x loop number (-1) to repeat the process of that row again but this time for the item from column D. I have added a Boolean variable 'Flg' to check if I have already checked the item in column D & it is not available, then put "N/A" & go to the next x number. To understand it correctly, I suggest that you take only 4-5 records & step through the code line by line pressing F8, I think it will become clearer for you

  13. #13
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Wow.. It is so surprising to see and learn the different ways of doing the same work. Sure, let me try on few records and understand it . Once again, thank you for your assistance

  14. #14
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Hi nankw83,

    Sorry to bother you again on the same code. While this code works great in most of the row items, there are still some rows where it is not giving the results. Issue is:
    We have matching keywords in Col.D but code gives us results as N/A. Below are few examples where the results shouldn't be N/A

    INC001056764153 - WAAS
    INC001056770946 - Infoblox
    INC001056547757 - Bandwidth
    INC001056565241 - ITRMS
    INC001056412829 - wireless

    I have also attached the macro file for your reference. Please assist.
    Attached Files Attached Files

  15. #15
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: Find specific text in a cell and update values in other cell

    Hi ...

    In the VBA editor, press Ctrl+H & the replace pop-up will appear, Find What: GoTo nxt Replace With: Flg = False: GoTo nxt

  16. #16
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    Okies, let me try Thank you

  17. #17
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: Find specific text in a cell and update values in other cell

    This seems working but when I use it with the new dataset, it gives me Runtime error: Mismatch at this step:
    HTML Code: 
    This is how variables are defined:

    HTML Code: 
    Please advise.

    Hi,

    Sorry to bother, but I got the issue fixed. There was a #NAME? in the summary column. I deleted it and the macro wored. Thank you as always
    Last edited by ruchikasharma9727; 09-04-2020 at 08:00 AM. Reason: Resolved the doubt

  18. #18
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Question Re: Find specific text in a cell and update values in other cell

    Hi nankw83,

    Hope you're doing good.

    Thank you for the code which you've shared earlier. It is being very helpful and working absolutely great!
    There is a new requirement which has come up as an extension to this code. If you could please assist, I will be really thankful to you. I'm sure this will be a piece of cake for you.

    What we have done so far:
    In the attached sheet, Col. V is being populated by finding the keywords in Col. C first and then in Col. D. Any non-matching entries will show as N/A

    New requirement:
    We need to do simliar activity now in Col.W for sub-category.
    For e.g. If Col.V is Port Open, then search for keywords in Col. C first and then Col. D for "Connectivity, AWS, AZURE". Upon encountering these words, give the desired results. If Connectivity encountered, result in Col.W should be Connectivity, if AWS found- results is "AWS" etc...

    I've attached the sample file.
    Raw Data sheet- Col.W (Results required)
    Keywords_Category sheet- Keywords for Sub-Category.

    Please assist.
    Attached Files Attached Files
    Last edited by ruchikasharma9727; 10-13-2020 at 10:25 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. Replies: 2
    Last Post: 06-29-2017, 02:08 PM
  2. Replies: 3
    Last Post: 12-28-2015, 08:14 AM
  3. [SOLVED] VBA to Find Specific Text, then Copy range to next open cell under specific text
    By Remotruker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2015, 10:59 AM
  4. [SOLVED] Find row cell containing specific text, then delete all rows ABOVE that cell
    By ks100 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 02:02 PM
  5. Replies: 2
    Last Post: 08-05-2013, 07:32 PM
  6. Replies: 0
    Last Post: 11-06-2012, 06:44 PM
  7. [SOLVED] UDF code to find specific text in cell comments, then average cell values
    By bruch04 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2005, 06:10 PM

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