Results 1 to 2 of 2

Thread: Code to pop up message when there is a variance

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    14

    Code to pop up message when there is a variance

    I have text "variance in Col A and values in Col D on several sheets. Where the value in Col D in the same row as the text "variance" is not equal to zero, then I want a message to advise where row number and sheet the variance is on

    I have written code to do this, but it tell me that there are variabnce in Col D when in fact they are zero

    Your assistance in resolving this is most appreciated

    HTML Code:
    Sub Variance_Message()
    
    Dim ws As Worksheet, r As Range, msg As String, ff As String
    For Each ws In Sheets
        Set r = ws.Columns("a").Find("Variance")
        If Not r Is Nothing Then
            ff = r.Address
            Do
                If (r.Offset(, 4).Value <> 0) Then
                               msg = msg & ws.Name & r.Address(0, 0)
                End If
                Set r = ws.Columns("a").FindNext(r)
            Loop Until ff = r.Address
        End If
    Next
    MsgBox IIf(Len(msg) > 0, msg, "No Variances Found")
    End Sub

    @Howardc, Edit your thread and wrap the code using code tag.
    Last edited by Howardc; 07-27-2013 at 03:53 PM.

Similar Threads

  1. Message To Cross Posters
    By Excel Fox in forum Public News
    Replies: 1
    Last Post: 11-09-2013, 02:07 AM
  2. VBA To Display Pop Up Alert When Duplicate Entry Is Made
    By peter renton in forum Excel Help
    Replies: 20
    Last Post: 07-26-2013, 07:56 PM
  3. VBA code message box added
    By rich_cirillo in forum Excel Help
    Replies: 6
    Last Post: 07-08-2013, 05:19 PM
  4. Message Box Pop-Up "yes or no"
    By Ryan_Bernal in forum Excel Help
    Replies: 1
    Last Post: 02-19-2013, 06:20 PM
  5. Conditional Format Based On Percentage Variance
    By srizki in forum Excel Help
    Replies: 3
    Last Post: 10-09-2012, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •