+ Reply to Thread
Results 1 to 6 of 6

If cell contains this then do this

  1. #1
    Registered User
    Join Date
    08-04-2022
    Location
    Blackburn
    MS-Off Ver
    Excel 2013
    Posts
    39

    If cell contains this then do this

    Okay, so I've been scouring the internet for info on if statements and I can only seem to find if statements that check if a cell contains ANY text. What I'm looking for is something like this...

    If the cell in Range(enter range) contains (type text her) then perform the following code

    or

    If cell contains this text then perform this different code

    I already have the correct codes written out which is working correctly. I just need to make it dependent on text in a different cell. So basically I have an account statement for two different accounts but they appear on the same statement. So when I process a transaction, I want it to bring the correct amount from the balance section for the correct account.

    Therefore, when cell says "Account 1" it should go and bring my current balance from account 1 and when the cell says "Account 2" it should go and bring me my balance from account 2. Thanks in advance. Current code I have for this macro is pasted below.
    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 08-06-2022 at 12:44 PM. Reason: please use code tags

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If cell contains this then do this

    There is no way to tell from your code what cell you want to check for "Account 1" and how to bring the balance from account 1.

    I suggest you attach your Excel file so we can see where your data is. See yellow banner at the top of the page.

    But here is the generic answer to the generic part of your question:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-04-2022
    Location
    Blackburn
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: If cell contains this then do this

    I have uploaded the file so hope this will allow you see what I'm trying to do.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-04-2022
    Location
    Blackburn
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: If cell contains this then do this

    Quote Originally Posted by 6StringJazzer View Post
    There is no way to tell from your code what cell you want to check for "Account 1" and how to bring the balance from account 1.

    I suggest you attach your Excel file so we can see where your data is. See yellow banner at the top of the page.

    But here is the generic answer to the generic part of your question:
    Please Login or Register  to view this content.
    Uploaded, if you click the process button on the set-up sheet. That's where I'm up to so far so when it adds the money to previous balance. I need that to be dependent on the account and bring the balance from the banking sheet.

  5. #5
    Registered User
    Join Date
    08-04-2022
    Location
    Blackburn
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: If cell contains this then do this

    Nevermind, the generic code worked, thanks

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: If cell contains this then do this

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking Add Reputation below their name.

+ 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] When one cell equals value of another cell, then third cell displays text of fourth cell?
    By spookymyo in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-12-2021, 02:12 PM
  2. [SOLVED] cell a function doing math on previous sheet, cell b - cell c result in cell d...
    By dad812 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-08-2018, 08:20 AM
  3. Replies: 6
    Last Post: 01-23-2018, 04:49 AM
  4. If Cell A is equal to Cell B replace the data from Cell A with Cell C. How can I do this.
    By tristanhathaway in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2014, 08:05 PM
  5. [SOLVED] How to create/run "cell A equals Cell B put Cell C info in Cell D
    By abmb161 in forum Excel General
    Replies: 7
    Last Post: 02-05-2014, 02:20 AM
  6. Replies: 1
    Last Post: 11-06-2013, 02:56 AM
  7. Replies: 1
    Last Post: 11-03-2012, 09:05 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