Results 1 to 6 of 6

auto generate a comment box based on a cell value that has variable reference cells

Threaded View

vamedic11 auto generate a comment box... 01-30-2010, 10:50 AM
Cheeky Charlie Re: auto generate a comment... 01-30-2010, 12:37 PM
vamedic11 Re: auto generate a comment... 01-30-2010, 02:30 PM
Cheeky Charlie Re: auto generate a comment... 01-30-2010, 04:54 PM
vamedic11 Re: auto generate a comment... 01-30-2010, 09:30 PM
Cheeky Charlie Re: auto generate a comment... 01-31-2010, 06:56 AM
  1. #1
    Registered User
    Join Date
    01-08-2010
    Location
    Sussex County, Delaware
    MS-Off Ver
    Excel 2013
    Posts
    40

    auto generate a comment box based on a cell value that has variable reference cells

    I have been given the following code and it works great. I now need to adapt it to the following scenario:

    In the attached sheet, the user has to select either, "Suburban" or "Squad" in row 5.
    If the user selects, "Suburban" I need this script to compare the values they enter in a given row to the value in column "B".
    If the user selects, "Squad" I need this script to compare the values they enter in a given row to the value in column "C".

    Look at row 48, for example. If the user enters, "Suburban" in cell D5 then the value they enter in cell D48 should equal "1". If it does not equal "1" then it should proceed with the adding of a comment. Conversely, if the user enters, "Squad" in cell D5 then the value the enter in cell D48 should equal "2". If it does not equal "2" then it should proceed with the adding of a comment.

    WHEW! Clear as mud?

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) 
         'I want to   exclude columns A and B as well as rows 1, 2, and 3.
        If Target.Column < 3 Or Target.Row < 4 Then Exit Sub 
        Dim MyCmmnt As String 
        If Sh.Name = "DATA" Then Exit Sub 
        On  Error Goto errorout 'Resume Next
        If Target.Value <> Cells(Target.Row, "B").Value Then 
            MyCmmnt = Application.InputBox("Briefly explain the discrepency", "Comment", Type:=2) 
            If MyCmmnt = "False" Or Len(Trim$(MyCmmnt)) = 0 Then Exit Sub 
            With Target 
                .AddComment 
                .Comment.Text Text:=Application.UserName & ":" & Chr(10) & MyCmmnt 
                .Comment.Visible = False 
            End With 
        End If 
    errorout: 
        Err.Clear 
    End Sub
    Attached Files Attached Files
    Last edited by vamedic11; 01-31-2010 at 10:15 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