+ Reply to Thread
Results 1 to 7 of 7

Running the same code twice in the same workbook

  1. #1
    Registered User
    Join Date
    04-05-2013
    Location
    tennessee
    MS-Off Ver
    excel 2010
    Posts
    6

    Running the same code twice in the same workbook

    I am using the following code to add a time stamp to my excel workbook. It works perfect when i put one instance of the code in my worksheet. If I add the modified code to the worksheet, thats when I run into problems. If I change the target columns to time stamp another part of the worksheet and add the code to the worksheet. It will either not stamp the sheet or tell me i have an ambiguous name. I add a 2 to the name so it will distinguish between the 2 sets of code and it will not stamp the worksheet. I have also created another worksheet and added the code with the information in the cells to the worksheet. I then put the code in the worksheet and it will time stamp there but when i link to the main page the date either doesnt appear or it shows as 5-6 random numbers and not the actual date. Here is what i am trying to do: I have a list of printers and information in one section of the worksheet. When I change a cell in a certain column, it time stamps it so we can track the most recent changes. I want to add this code again to do the same thing for another column. I prefer not to have separate worksheets because of being able to see and modify all the information on 1 sheet. (and trying with another worksheet has failed on the link view)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column >= 3 And Target.Column <= 3 Then
    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With
    Cells(Target.Row, 5) = Date
    With Application
    .EnableEvents = True
    .ScreenUpdating = True
    End With
    End If
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Running the same code twice in the same workbook

    WHat are the two columns you want to test for change and what are their respective columns to receive their time stamp?

  3. #3
    Registered User
    Join Date
    04-05-2013
    Location
    tennessee
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: Running the same code twice in the same workbook

    When an item in column 3 is changed i want it to be stamped in the corresponding cell in column 5 and when 17 is changed i would like it to time stamp in 18.

  4. #4
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Running the same code twice in the same workbook

    I'm new at this, and I'm not sure exactly what you are attempting to do... but try this:
    Please Login or Register  to view this content.
    This what I use for my spreadsheets. You may want to set it to
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-19-2012
    Location
    Redmond, WA
    MS-Off Ver
    O365
    Posts
    133

    Re: Running the same code twice in the same workbook

    Quote Originally Posted by aarond5 View Post
    ... as 5-6 random numbers and not the actual date.
    I believe this is the formatting of the cell. Right click and check... It may not be set correctly...

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Running the same code twice in the same workbook

    Format columns 5 and 18 with a date format of your choosing.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-05-2013
    Location
    tennessee
    MS-Off Ver
    excel 2010
    Posts
    6

    Re: Running the same code twice in the same workbook

    Thank you very much AlphaFrog! That did exactly what I needed it to! I really need to start studying up on my programming!

+ 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