+ Reply to Thread
Results 1 to 3 of 3

Adjust cell contents based on another cells contents

  1. #1
    Registered User
    Join Date
    12-01-2017
    Location
    New Jersey
    MS-Off Ver
    2016
    Posts
    63

    Adjust cell contents based on another cells contents

    Hello,
    I am attempting to allow cell M6 to remain blank for manual entry as well as autofill based on the value of another cell.I have attempted 2 version of code that I loaded into the sheet code, but neither work. If cell L4 = N, cell M6 stays blank. If L4 = Y, then cell M6 get a formula of NOW & another cells contents to create a unique value. I'm fairly new to coding. Any help will be greatly appreciated.

    Private Sub Worksheet_Change(ByVal target As Range)

    If Range("L4").Value = "N" Or .Value = "" Then Exit Sub
    Application.EnableEvents = False

    If Range("L4").Value = "Y" Then

    ActiveSheet.Range("M6").Formula = "=text(NOW(),""mm/dd/yy/h:mm"")"
    Application.EnableEvents = True

    End Sub

    Version 2

    Private Sub Worksheet_Change(ByVal target As Range)

    If .Range("L4").Value = "N" Then
    .Range("M6").Value = ""
    ElseIf .Range("L4").Value = "Y" Then
    .Range("M6").Formula = "=text(NOW(),""mm/dd/yy/h:mm"""

    End With
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Adjust cell contents based on another cells contents

    Is L4 entered manually, then you can just set it as the target cell.
    Also if you are testing worksheet change events and all of a sudden nothing is happening, it would be a good idea to just close the progam and reopen it, the enableevents can be out of wak from testing the code.

    Enable events should not be required if you set the target

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-01-2017
    Location
    New Jersey
    MS-Off Ver
    2016
    Posts
    63

    Re: Adjust cell contents based on another cells contents

    Hi davesexcel,L4 is a manual entry and the code works great. Thank You Its funny you mentioned enablevents and system being out of wak. I found that after sending this request.
    Thanks again

+ 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. Replies: 3
    Last Post: 06-29-2015, 03:03 PM
  2. [SOLVED] Copy Paste Contents based on contents in designated cell
    By nickmessick1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2014, 01:23 PM
  3. [SOLVED] Clear contents based on contents of another cell
    By Katrina DTE in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-13-2013, 02:44 PM
  4. Replies: 6
    Last Post: 12-07-2012, 05:38 PM
  5. [SOLVED] Combine Cell Contents to with a [return] or [fill with spaces] between each cells contents
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2012, 11:24 PM
  6. [SOLVED] Adjust Multiple Cell Borders Based on Cell Contents
    By USFishin in forum Excel General
    Replies: 16
    Last Post: 04-10-2012, 12:56 AM
  7. Deleting cells based on contents or displayed contents
    By thebottomline in forum Excel General
    Replies: 3
    Last Post: 02-24-2010, 09:10 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