+ Reply to Thread
Results 1 to 4 of 4

Thread: run code if only cell is edited.

  1. #1
    Registered User
    Join Date
    06-27-2011
    Location
    srilanka
    MS-Off Ver
    Excel 2007
    Posts
    3

    Unhappy run code if only cell is edited.

    i have written this code in order to track cell changes in column 5 and enter current time stamp of cell changed in to a cell in column 4.what i want to achieve is that time stamp should only changed if i change value of a cell in column 5 only.but here in this code even if i click on a cell in column 5 it adds current time stamp in to column 4.please help on this.
    thanks.
     
    Private Sub Worksheet_Change(ByVal Target As Range)
    SelectionChange(
        If Target.Count > 1 Then Exit Sub
        If Target.Column <> 5 Then Exit Sub
    
        Target.Offset(0, -1) = Now
        
    
    End Sub
    Last edited by pubudu; 06-28-2011 at 05:52 AM.

  2. #2
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: run code if only cell is edited.

    Please edit your post to include code tags as per the forum rules

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button).
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: run code if only cell is edited.

    You seem to contradict yourself in your explanation. The code you have posted (other than the random 'SelectionChange(' bit which should be removed will put a date/time stamp in the adjacent cell in column 4 if a change is made in column 5.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,228

    Re: run code if only cell is edited.

    See your duplicate post for a workaround.

    http://www.excelforum.com/excel-prog...e-changed.html

    Regards

+ 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.2.0