Results 1 to 7 of 7

Cant Figure Out Syntax For Range As A Variable

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-29-2019
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    156

    Cant Figure Out Syntax For Range As A Variable

    Hi, Im having a problem with using range variables, basically the CriteriaValue variable refuses to work correctly, & gives errors whenever its called ... Im pretty sure its the syntax, & not sure how to fix it ...

    This is a basic countif script, but cant get the main variable to use the countif to work, this is stored in CriteriaValue.

    Thanks

    Sub ValleyDips()
    
    Dim ValuesRange As Range
    Dim ResultCell As Range
    Dim CriteriaValue As Range
    
    
    
    Set ValuesRange = Range("A1:A4")
    Set ResultCell = Range("C3")
    
    Set CriteriaValue = Range("A1")
    
    HighestCurentValue = Range(CriteriaValue).Value
    
    For j = 1 To 4
    
    
        ResultCell = Application.WorksheetFunction.CountIf(ValuesRange, "<" & Range(CriteriaValue))
        
        If ResultCell > 3 Then
    
            d = ValuesRange.Offset(i, 0).Address
            i = i + 1
            MsgBox d & HighestCurentValue
            
            End If
    
        
        
        If ResultCell < 3 Then
    
            d = CriteriaValue.Offset(i, 0).Address
            i = i + 1
            MsgBox d & HighestCurentValue
            
            End If
    
    
    Next j
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. cell range variable syntax
    By Estaban9850! in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-28-2016, 09:44 AM
  2. [SOLVED] Syntax for Using Range with a Variable Column
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2013, 12:36 PM
  3. Countifs VBA Syntax - variable row range
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2011, 04:16 PM
  4. Refer to a range(row 20 : variable), syntax help
    By VBAHelpMe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2009, 09:01 AM
  5. Syntax for Range command with a variable
    By nebb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-11-2007, 12:14 PM
  6. syntax - range name as a variable
    By Peter Morris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2006, 02:15 PM
  7. Syntax to Set variable range
    By Mike Fogleman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2005, 05:15 PM

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