+ Reply to Thread
Results 1 to 2 of 2

Target Offset and Clear Contents

  1. #1
    Registered User
    Join Date
    12-11-2007
    Posts
    1

    Target Offset and Clear Contents

    hi

    When I select an option for a drop down list in B2, the date is automatically date/time stamped in cell C3. My problem is

    1.) I need the date/time stamped in cell A2 instead.
    2.) If there is no value in cell B2, the contents in cell A2 is to be cleared

    Someone helpful provided me the following code in my worksheet

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("B2", "B10")) Is Nothing Then
    Target.Offset(1,0).Value = Date & " - " & Time
    End If

    End Sub

    I tried putting different values in Target.Offset but I don't seem to understand it. I tried doing the following below but it just doesn't work properly.

    If Intersect(Target, Range("B2", "B10")) Is Nothing Then
    Target.Offset(1,0).clearcontents
    End If

    Can someone show me what's wrong?

    Thanks

    Marlene

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Marlene.

    The Offset(1, 0) function says to move down 1 row and to the right 0 columns. So if the target range is B2, and you want to enter the date and time into A2, you want to offset 0 rows, and -1 column. So change:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    And by the way, in the future, please wrap all code in CODE tags by putting [ CODE ] and [ / CODE ] around the code (without the spaces).

    HTH

    Jason

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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