Results 1 to 5 of 5

Modify Code to Log Cell Input and Value

Threaded View

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Modify Code to Log Cell Input and Value

    I submitted a post awhile back that was beautifully solved by 6StringJazzer to log user responses to a data entry validation via VB for Excel.

    The post is herehttp://www.excelforum.com/excel-prog...alidation.html

    However, I received another request from a colleague of mine that it'd be nice that in the log that was created, it could also log the cell location AND value input. It seems like this would be possible b/c I can see exactly where the line in the code that prints out the current information and I just need it to be expanded to also log where the value was entered (cell location) as well as the value the user enters.

    Can anyone assist with this?

    Here is the code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
       Dim answer As String
       
       If Target.Count = 1 Then
          If Target.Value > Sheet2.Range("threshold") Then
          
             formAsk.Show
             answer = formAsk.textboxWhom
             If answer <> Sheet2.Range("rightname") Then
                MsgBox "Please contact RP ALARA for dose approval."
             End If
             
             On Error GoTo BackupFile
             Open ThisWorkbook.Path & "\responselog.txt" For Append Access Write Lock Write As #2
             On Error GoTo 0
             
             Dim ThisUser As String
             'thisuser = Application.username ' registration in MS Office
             ThisUser = Environ("USERNAME") ' Windows login
             
             Print #2, Now & " User: " & ThisUser & " Response: " & answer         Close 2
             
          End If
       End If
       
       
       Exit Sub
       
    BackupFile:
             Open ThisWorkbook.Path & "\responselog2.txt" For Append Access Write Lock Write As #2
             Print #2, Now & " User: " & ThisUser & " Response: " & answer
             Close 2
       
    End Sub
    Thanks
    Last edited by HP RodNuclear; 09-12-2011 at 10:14 AM.

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