Results 1 to 10 of 26

Thread: Macro to check values based on certain text

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Howardc, what admin has posted is working fine on the sample file you've attached. Also, the bracket should be ), and not the other way around.

    Once again,
    Code:
    Evaluate("sumproduct(--(abs(" & myRange.Address(external:=1) & ")>0.0001)," & myRange.Address(external:=1) & ")")
    is correct. Do you want to attach a sample file again, in case this is not working?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    14
    Hi Excelfox

    Thanks for the reply. See full code below

    When running the macro, it comes up with "type mismatch 13" and the folowing code is highlighted


    If cCell.Offset(0, i) <> 0 Then

    It would be appreciated if you could assist me






    Code:
    sub Check_Variance()
                Dim sh  As Worksheet, cCell As Range
                Dim cAddress As String, lastRowSH1 As Long, i As Long
                Dim startCell As Range, endCell As Range, myRange As Range
    
    
                For Each sh In Worksheets
                    If UCase(sh.Name) <> "CONSOLIDATED" Then
                        cAddress = ""
                        
                        With sh
                            lastRowSH1 = .Range("B" & .Rows.Count).End(xlUp).Row
                            For Each cCell In .Range("A1:A" & lastRowSH1)
                                Debug.Print sh.Name
                                Debug.Print cCell.Value
                                If UCase(cCell.Value) = "CHECK" Then
                                    Set startCell = .Range("B" & cCell.Row)
                                    Set endCell = .Range("Z" & cCell.Row)
                                    Set myRange = .Range(startCell, endCell)
                
                              Evaluate("sumproduct(--(abs(" & myRange.Address(external:=1) & ")>0.0001)," & myRange.Address(external:=1) & ")") 
                               
                                        For i = 1 To 26
                                            If cCell.Offset(0, i) <> 0 Then
                                                If cAddress = "" Then
                                                    cAddress = cCell.Offset(0, i).Address
                                                Else
                                                    cAddress = cAddress & ", " & cCell.Offset(0, i).Address
                                                End If
                                            End If
                                        Next i
                                    End If
                                
                            Next cCell
                            If cAddress <> "" Then
                                MsgBox "Please check the following address(es) on " & sh.Name & vbNewLine & vbNewLine & cAddress
                            End If
                        End With
                    End If
                Next sh
            End Sub
    Last edited by Admin; 11-01-2012 at 05:32 PM.

Similar Threads

  1. Sum values based on multiple criteria
    By Jorrg1 in forum Excel Help
    Replies: 8
    Last Post: 01-07-2013, 03:04 PM
  2. Replies: 10
    Last Post: 12-10-2012, 11:28 PM
  3. Offset based on Values in Column E
    By mrmmickle1 in forum Excel Help
    Replies: 7
    Last Post: 12-04-2012, 10:06 AM
  4. Macro to clear data based on color fill
    By Howardc in forum Excel Help
    Replies: 7
    Last Post: 12-03-2012, 09:25 AM
  5. Loop and Check For Values In Entire Column in Excel
    By Jeff5019 in forum Excel Help
    Replies: 3
    Last Post: 05-01-2012, 10:34 PM

Posting Permissions

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