Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: VB using if statement

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello,
    I was wondering if anyone knows how to use an if statement in this context. If a cell has a numerical value then perform such and such operation i.e. if cell is a number then divide by two and put in another cell, otherwise do nothing.
    thanks for any advice you could give
    Casey

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Suppose Cell "A1" on "Sheet1" holds the value, suppose cell "B1" on the same sheet is to hold the result, you would use the "if" statement like this:


    With Sheets("Sheet1")
    If IsNumeric(.Range("A1").Value) Then
    .Range("B1").Value = .Range("A1").Value / 2
    End If
    End With

    HTH

    _________________
    [b] Mark O'Brien

    [ This Message was edited by: Mark O'Brien on 2002-05-10 11:35 ]

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thankyou very much I didnt know there is a Isnumeric function.
    thanks again
    Casey

Some videos you may like

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
  •