+ Reply to Thread
Results 1 to 7 of 7

VBA If cell does not contain

  1. #1
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Question VBA If cell does not contain

    Hi all,

    I'm after a line of code which determines whether a cell does not contains the word "Saturday" or "Sunday".

    The code I'd written below doesn't work:
    Please Login or Register  to view this content.
    An example of the format of the cells this macro will run through is as follows: Monday 27th, June 2022. These cells are in column E, hence the 5 in my code

    Thanks!

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,360

    Re: VBA If cell does not contain

    Are these dates that have been formatted to look this way or are they text strings?
    If things don't change they stay the same

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA If cell does not contain

    Depending on the answer to the above question, you'd need something like:

    Please Login or Register  to view this content.
    to check for weekdays in text.
    Rory

  4. #4
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,360

    Re: VBA If cell does not contain

    Maybe something like the below if they are real dates:
    Please Login or Register  to view this content.
    Last edited by CheeseSandwich; 06-27-2022 at 05:57 AM. Reason: Changed > 6 to > 5 (typo)

  5. #5
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Re: VBA If cell does not contain

    Quote Originally Posted by rorya View Post
    Depending on the answer to the above question, you'd need something like:

    Please Login or Register  to view this content.
    to check for weekdays in text.
    Hi Rory, Yes it's formatted as just a string.
    Unfortunately that doesn't work either. Rows with Saturday and Sunday are still being picked up.

    I've attached an Excel with my code, using your solution which doesn't seem to work.
    Attached Files Attached Files

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA If cell does not contain

    Sorry, I misread your code. It should be:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Re: VBA If cell does not contain

    Quote Originally Posted by rorya View Post
    Sorry, I misread your code. It should be:

    Please Login or Register  to view this content.
    Works a charm, thanks very much!

+ 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

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