Results 1 to 5 of 5

Using the target command to start user form macro

Threaded View

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

    Using the target command to start user form macro

    The following is code I am using to start a user form macro that will start a dialog box asking the user if they've received approval to exceed a specified threshold:
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
       Dim answer As String
       
       If Not Intersect(Target, Sheet8.Range("I5:U5")) Is Nothing Then
          If Target.Value > Sheet15.Range("threshold") Then   
       
            formAsk.Show
             answer = formAsk.TextboxWhom
             If Sheet15.Range("therightname").Find(what:=answer) Is Nothing Then ' modified
                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
    However, I can't get it to work right b/c when I change a cell value in the range I5:U5, the macro does not run (see the bolded portion in the code). I know this code works b/c I submitted a dummy workbook months ago and the code works for the dummy workbook, but when I tried to modify the code to match the actual workbook I am using, I couldn't get it to work right. Furthermore, the range I am working with is not a continous range and I want to make sure I input the right syntax for non-contiguous range as well. Any help would be greatly appreciated

    Thanks.

    HP RodNuclear
    Last edited by HP RodNuclear; 06-07-2011 at 02:36 PM.

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