+ Reply to Thread
Results 1 to 2 of 2

A VB problem with a if structure

  1. #1
    filo666
    Guest

    A VB problem with a if structure

    Hi, trayng the following macro:
    bla bla bla
    If Cells(contr, 1) = NumeroDeControl Then
    comp = 1
    end if
    bla bla bla

    an error apears (ERR 2042), this happends because in the cell( contr,1) I
    have the #N/A, but we know (you and me, because VB didn't)THE IF STRUCTURE IS
    FALSE so my macro should jump the comp=1
    How to thell VB that no matter what kind of value are in cells(contr,1) the
    if structure must continue

    I've tried everithing (declaring NumeroDeControl as string didn't work, not
    declaring at all NumeroDeControl neither)
    HTHS
    TIa

  2. #2
    bpeltzer
    Guest

    RE: A VB problem with a if structure

    Check for the error before testing for the value:
    If Not (IsError(Cells(1, 1))) Then
    If Cells(1, 1) = NumeroDeControl Then
    comp = 1
    End If
    End If


    >"filo666" wrote:


    > Hi, trayng the following macro:
    > bla bla bla
    > If Cells(contr, 1) = NumeroDeControl Then
    > comp = 1
    > end if
    > bla bla bla
    >
    > an error apears (ERR 2042), this happends because in the cell( contr,1) I
    > have the #N/A, but we know (you and me, because VB didn't)THE IF STRUCTURE IS
    > FALSE so my macro should jump the comp=1
    > How to thell VB that no matter what kind of value are in cells(contr,1) the
    > if structure must continue
    >
    > I've tried everithing (declaring NumeroDeControl as string didn't work, not
    > declaring at all NumeroDeControl neither)
    > HTHS
    > TIa


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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