Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    196
    Thanks
    1
    Thanked 0 Times in 0 Posts

    If Range is NOT NULL... (2003)

    I need help with how to write code to check my Range("A60:A101") and see if it contains anything, text or numberic.

    thanks,
    jackal

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: If Range is NOT NULL... (2003)

    Not sure what you want, does this example help you out?

    Steve

    <pre>Option Explicit
    Sub TestTypes()
    Dim lBlanks As Long
    Dim lNumbers As Long
    Dim lText As Long
    Dim rng As Range

    Set rng = Range("A60:A101")
    With Application.WorksheetFunction
    lBlanks = .CountBlank(rng)
    lNumbers = .Count(rng)
    lText = .CountA(rng) - lNumbers
    End With
    MsgBox "Range: " & rng.Address & _
    " contains: " & vbCrLf & _
    lNumbers & " Numbers" & vbCrLf & _
    lText & " Text Strings" & vbCrLf & _
    lBlanks & " Blank cells"
    Set rng = Nothing
    End Sub</pre>


    Or are you just looking for the lines:
    if Application.WorksheetFunction.CountA(Range("A60:A1 01")) = 0 then
    'Your code here
    end if

    Steve

Posting Permissions

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