Can I enter a formula to count values in VBA
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Can I enter a formula to count values in VBA

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    The code below runs a function to get data from closed workbooks. Where it specifies range "AD:AD" can i put a formula in to count if range AD contains certain values??




    cValue = GetInfoFromClosedFile(FolderName, wbList(i), wsName, ("AD:AD"))


    Cells(r, 2).Formula = cValue

    Private Function GetInfoFromClosedFile(ByVal wbPath As String, wbname As String, wsName As String, cellRef As String) As Variant
    Dim arg As String

    GetInfoFromClosedFile = ""
    If Right(wbPath, 1) <> "" Then wbPath = wbPath & ""
    If Dir(wbPath & "" & wbname) = "" Then Exit Function
    arg = "'" & wbPath & "[" & wbname & "]" & wsName & "'!" & Range(cellRef).Address(True, True, xlR1C1)



    On Error Resume Next
    GetInfoFromClosedFile = ExecuteExcel4Macro(arg)
    End Function

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi
    I don't know if you can or not. Try it. Search help for "Using Excel Functions in Your Code"
    If not, you can always loop down the column and check the cells individualy..
    Tom

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com