+ Reply to Thread
Results 1 to 3 of 3

vba ...if then on base of "cell contains xxx" instead of cell = "xxx"

  1. #1
    Registered User
    Join Date
    08-13-2020
    Location
    Brussels
    MS-Off Ver
    windows 10
    Posts
    4

    Red face vba ...if then on base of "cell contains xxx" instead of cell = "xxx"

    Dears would like to modify below vba macro … into.... if cell contains certain data instead of specific text
    fi below VBA
    if Range ("a2").Value = "a" Then
    Range ("b2").Value = "1"
    ElseIf Range ("a2).Value = "b" Then
    Range ("b2").Value = "2"
    ElseIf Range ("a2).Value = "c" Then
    Range ("b2").Value = "2"
    End If
    End Sub

    Would like to have outcome 1 if data in cell a2 contains an "a" ….. I tried "*a*" but it is not going.
    Can someone help me please
    Thanks
    Danny

  2. #2
    Registered User
    Join Date
    07-02-2013
    Location
    Cheshire
    MS-Off Ver
    Office Professional 2007
    Posts
    79

    Re: vba ...if then on base of "cell contains xxx" instead of cell = "xxx"

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

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: vba ...if then on base of "cell contains xxx" instead of cell = "xxx"

    Hi danny and welcome to the formum,

    You might like the like operator. See https://analystcave.com/vba-like-operator/
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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] Add V/W into "Open/Training" column " C ", "Ride/Base"
    By Potholes in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-14-2019, 05:59 AM
  2. [SOLVED] Identify specific numeric values in a cell such as "1" without counting "11" as two "1"s
    By MHanna39 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-03-2019, 01:35 PM
  3. Replies: 5
    Last Post: 02-05-2019, 12:03 AM
  4. Replies: 2
    Last Post: 07-13-2018, 11:52 PM
  5. Replies: 4
    Last Post: 06-11-2017, 02:03 PM
  6. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  7. [SOLVED] VBA help needed to remove all "/" then replace with "-" from cell "B3"and "B5"
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 02:11 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