+ Reply to Thread
Results 1 to 2 of 2

Save changes in LogSheet after changing a cell-value in a specific column in another sheet

Hybrid View

Matt81a Save changes in LogSheet... 02-06-2013, 02:09 PM
Matt81a Re: Save changes in LogSheet... 02-07-2013, 01:19 PM
  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Save changes in LogSheet after changing a cell-value in a specific column in another sheet

    Dear all,

    Hope someone can help me. In fact I do have two problems with my code...
    I am absolutely not familiar with VBA and would like to keep the code as simple as possible.

    (1)
    The code I work with works fine if I change any value in any cell in the worksheet. BUT I would like to set a condition that saves the changes ONLY if I change the value in column G. How can I do that?

    (2)
    As I said, the changes are saved in the Log-Sheet but it overwrites the former content.
    An example:
    If I change column G12 in the original worksheet, the Log-Sheet saves the changes in the cells A2-E2.
    If I change column G17 in the original worksheet, the Log-Sheet saves the changes in the cells A2-E2. But I would like to save the new changes in a new row (creating a list of changes over the course of the time).

    This is the failing code I have so far:

    - - -
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim LR As Long
    If Sh.Name = "Log" Then Exit Sub
    Application.EnableEvents = False
    With Sheets("Log")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("A" & LR + 1).Value = Range("F" & Target.Row).Value
    .Range("B" & LR + 1).Value = Range("G" & Target.Row).Value
    .Range("C" & LR + 1).Value = Range("A" & Target.Row).Value
    .Range("D" & LR + 1).Value = Range("B" & Target.Row).Value
    .Range("E" & LR + 1).Value = Range("E" & Target.Row).Value
    .Range("F" & LR + 1).Value = Now
    End With
    Application.EnableEvents = True
    End Sub
    - - -


    My code is based on this code (I found in your forum) and it creates a list (just as I want to) but if I apply my changes in the code it does not create a list anymore but overwrites the former content in the cells. Any ideas?

    - - -
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim LR As Long
    If Sh.Name = "Log" Then Exit Sub
    Application.EnableEvents = False
    With Sheets("Log")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("A" & LR + 1).Value = Now
    .Range("B" & LR + 1).Value = Sh.Name
    .Range("C" & LR + 1).Value = Target.Address(False, False)
    .Range("D" & LR + 1).Value = Target.Value
    End With
    Application.EnableEvents = True
    End Sub
    - - -

    Please help!
    The desperate Matt81.
    Last edited by Matt81a; 02-07-2013 at 11:21 AM.

  2. #2
    Registered User
    Join Date
    01-21-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Save changes in LogSheet after changing a cell-value in a specific column in another s

    UPDATE:

    The Log-Sheet creates a list now. So problem (2) is solved. But I still need some help with the condition. It shouldn't be too hard but I feel like running in circles...
    Since I haven't made any mayor changes to the code above I am not going to repost the current code.

    What I still need is a piece of VBA code that checks Sheet1 for changes in column G. If their is a change than copy the data of the same row into another worksheet (Log).

    I count on you!
    Matt81a

+ 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