+ Reply to Thread
Results 1 to 2 of 2

How to not execute code when cell contains data

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2018
    Location
    South Carolina
    MS-Off Ver
    2010
    Posts
    1

    How to not execute code when cell contains data

    I am working on a sheet, and do not want the date to change once it has been entered.


    This is the code I am using but if someone enters something other than :'Sets the Time when Selecting "Bay" then reselects "Bay" the time adjusts to the current time not the original time that was entered.


    For Each Cell In Target
    If Cell.Column = Range("M:M").Column Then

    If Cell.Value = "Bay" Then
    Cells(Cell.Row, "O").Value = (Time)
    Else
    'do nothing
    End If
    End If
    Next Cell

    'Sets the Time when Selecting Bay
    For Each Cell In Target
    If Cell.Column = Range("M:M").Column Then

    If Cell.Value = "Bay" Then
    Cells(Cell.Row, "O").Value = (Time)
    Else
    'do nothing
    End If
    End If
    Next Cell

    That you in advance for your help.

  2. #2
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    492

    Re: How to not execute code when cell contains data

    Hi

    How about trying this..
    For Each Cell In Target
    If Cell.Column = Range("M:M").Column Then
    
    If Cell.Value = "Bay" Then
    If Cells(Cell.Row, "O").Value = "" Then
    Cells(Cell.Row, "O").Value = (Time)
    Else
    'do nothing
    End If
    End If
    End If
    Next Cell
    zeddy

+ 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. code to execute a keyboard shortcut or to execute a toolbar button
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2015, 12:16 PM
  2. [SOLVED] Execute code for first cell match
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-03-2014, 03:41 PM
  3. [SOLVED] Automatic code to execute only if certain cell is empty
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2014, 10:49 PM
  4. When cell changes, execute code
    By kirkland in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-15-2012, 09:06 AM
  5. macro to execute code from cell.value?
    By wamp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2010, 04:29 AM
  6. Execute code based on cell entry
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-29-2009, 01:38 PM
  7. How can I use VB code to execute macro when double-clicking cell?
    By JDay01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2006, 10:20 AM

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