+ Reply to Thread
Results 1 to 24 of 24

VBA Macro Searching for specific text

  1. #1
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    VBA Macro Searching for specific text

    Hello everyone,

    I am trying to convert below formula to VBA Macro in excel and I was wondering if anybody can help me with that. I initially started but I can not put all condition into the code because my VBA knowledge is limited. Would you please help me?


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thank you so much for your help in advance!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA Macro Searching for specific text

    Hi, welcome to the forum

    What exactly are you trying to do here, and why do you need VBA for that?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Good Morning Ford,

    I am trying to tag the transactions type by searching through transaction description in column "D" for transfer between accounts. If the description in column "D" has word "Transfer" I want to have word "Transfer" to show in my column "B" of my worksheet. If it sees word "Transfer" along with "Fee" in the description, I want to tag the transaction for word "Debit" in column "B" of my worksheet and finally if non of that possibilities, then looks at my amount in column "I" if the number is negative, tag my transaction with "Debit" in column "B" and if my amount in column "I" is positive, tag my transaction with word "Credit" in column "B".

    Thank you for your help!

    Regards,

    Saeidian

  4. #4
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Good Afternoon Ford,

    Here is what I am trying to do! Would you please look at this when you have a minute and tell me if you could help me with it?

    Basically this formula is doing the following.

    1- Searches column D cell “D2” for word “Transfer” not cap sensitive. (TRANSFER, Transfer, transfer)
    2- If it finds word “Transfer” it will enter word “Transfer” in column C cell “C2” of my worksheet.
    3- If it finds word “Transfer” in conjunction with word “Fee” it will enter word “Check” in column “C2” of my worksheet.
    4- If there is no word “Transfer” and there is no word “Transfer” along with word “Fee” to be found in my column “D” cell D2 then
    5- It looks at my column “I” cell I2, if “I2” is below zero then it enters word “Check” in “C2” if “I2” greater that zero it will enter word “Deposit” in cell “C2”
    6- It will test every cell in column D and return the same result
    7- The search stops If cells in column “I” is blank

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: VBA Macro Searching for specific text

    My VBA is weak, but Im sure if you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like, 1 of the other members will pick this up and help you

  6. #6
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Thank you Ford! I have attached a excel sheet with two taps one before and one after. Hope someone could help me!
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    See B7 in result is different from yours.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Hello Jindon,

    I really appreciate your help! That works perfect! It does the job perfectly. The only thing is that I wanted the result in column "C" instead of column "B". I thought I could change the code by myself and alter it but it seems that I am unable to do it.

    Best Regards,

    Saeidian

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    If sheet layouts are different, no body can answer.

  10. #10
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Hello,

    I am really sorry to bother you. Everything stays the same way, except data will populate in column C instead. Please see attached sample file.
    It shifts on column to the right.

    Regards,

    Saeidian
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    Change to
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: VBA Macro Searching for specific text

    You can use this code also :
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Thank you so much to both of you! Wow you guys are amazing!

  14. #14
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: VBA Macro Searching for specific text

    You are most welcomed.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    If that takes care of your original question, select Thread Tools from the menu link above and mark this thread as SOLVED.

  16. #16
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: VBA Macro Searching for specific text

    Another code without Worksheet Formula coding:

    PHP Code: 
    Sub transaction()
    Dim TemArr()
    Dim DesArr As Range
    Dim i
    Find As Long
    Set DesArr 
    Range("D2:J" & [J2].End(xlDown).Row)
    ReDim TemArr(1 To DesArr.Rows.Count1 To 1)
        For 
    1 To UBound(TemArr)
            
    Find InStr(1DesArr.Cells(i1), "transfer"vbTextCompare)
                
    Select Case Find
                    
    Case Is 0
                        
    If (InStr(1Space(1) & DesArr.Cells(i1) & Space(1), Space(1) & "fee" Space(1), vbTextCompare) > 0) Or _
                        
    (InStr(1Space(1) & DesArr.Cells(i1) & Space(1), Space(1) & "fees" Space(1), vbTextCompare) > 0Then
                            TemArr
    (i1) = "Check"
                        
    Else:
                            
    TemArr(i1) = "Transfer"
                        
    End If
                    Case 
    Is 0
                        
    If DesArr(i7) < 0 Then
                           TemArr
    (i1) = "Check"
                        
    Else:
                           
    TemArr(i1) = "Deposit"
                        
    End If
                
    End Select
        Next i
        
    [C2].Resize(UBound(TemArr), 1) = TemArr
    End Sub 
    Quang PT

  17. #17
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Hello,

    you helped me last year with below vba code and it works for me perfectly. However, I would like to through another condition to the following coding, which it recognizes "Overdraft Protection" in the memo as Transfer as well in addition to this statement If a(i, 1) Like "*transfer*". I tried to add another if statement like " if a(I, 1) Like "*Overdraft Protection*" but I receive compiling error.
    Would you please advice?

    I really appreciate your help in advance.



    Please Login or Register  to view this content.

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    If you get compiling error, that's because you didn't change the code properly.
    That's all I can say.

  19. #19
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Thank you Jindon.

  20. #20
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Hello Jindon,

    I played around with this all this morning and It does not give me the compile error anymore which is great but it recognizes the "OVERDRAFT PROTECTION" not "transfer". In essence insets word transfer for transaction that includes "OVERDRAFT PROTECTION" but inserts word Check or Deposit instead of Transfer for transactions that have transfer. Any suggestions would be GREATLY APPRECIATED!

    Please Login or Register  to view this content.
    Last edited by Saeidian; 09-26-2017 at 04:34 PM.

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    Then I need to see your file with data/result.

  22. #22
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Hello Jindon, Please see attached sample.

    Thank you again for looking to this .
    Attached Files Attached Files

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA Macro Searching for specific text

    You mean
    Please Login or Register  to view this content.
    ?

  24. #24
    Registered User
    Join Date
    07-28-2016
    Location
    United State
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA Macro Searching for specific text

    Yes, it works now. Thank you so much for your assistant. Have a great weekend.

+ 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 through table for a specific text
    By kranman85 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-10-2016, 10:14 PM
  2. Searching Specific Cells for Specific Text
    By sebbie99 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-21-2014, 02:53 PM
  3. [SOLVED] Searching a Range for a Specific Text and put a different text in a different cell
    By AngelAzrael in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-14-2013, 09:25 AM
  4. Replies: 19
    Last Post: 04-10-2013, 08:30 AM
  5. Searching for Specific Text in a Row
    By NewExcelUser in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-06-2007, 10:22 PM
  6. Searching for specific text within a cell
    By plannerg in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2006, 05:38 PM
  7. [SOLVED] searching for specific text
    By clerk in forum Excel General
    Replies: 1
    Last Post: 12-06-2005, 08:20 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