Results 1 to 3 of 3

Thread: VB AND EXCEL ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 1999
    Posts
    3

    Post

    Hey guys, I am having trouble with this function:

    _________________
    Function DelState(c As Object)
    Dim x1, y1 As Integer
    x1 = 1
    y1 = 10
    Do
    If c.Text <> "CT" Or "DC" Or "IN" Or "MA" Or "MD" Or "ME" Or "MI" Or "NH" Or "NJ" Or "OH" Or "PA" Or "RI" Or "VT" Or "WI" Or "WVA" Then
    Call DeleteRow(x1, y1)
    End If
    x1 = x1 + 1
    Loop Until x1 = maxrows + 1
    End Function
    __________________

    I have an excel worksheet as an object and I am trying to test for the text not the values in a cell. But c.text gives me a type error.
    What shall i do.

    P.S. The rest of the prog works fine...



  2. #2
    Guest

    Post

    Maybe the cells are formatted as numbers not text, that would explain why you would get a
    type mismatch error. But this is just a wild guess.

  3. #3
    Lively Member
    Join Date
    Jun 1999
    Location
    Raleigh, NC
    Posts
    70

    Post

    The problem is in your compare statement... you need to try it this way...

    if c.Text <> "CT" and c.Text<> "DC" and c.Text <> "IN" ... etc...

    You are getting a type mismatch because you are doing a logical statment (c.Text <> "CT") and then you are doing a logical OR with a string.

    Bash

Posting Permissions

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



Click Here to Expand Forum to Full Width