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

Thread: If Integer Do Something

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

    Default

    I have a division in my code. I am trying to say if the division ends in integer, do something. For example,
    Dim x as Integer
    Dim y as Integer
    if x/y= Integer???
    do bla bla bla.
    Thanks.

  2. #2
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi. Here is sample what I made.
    Pls try this.


    Sub test()
    Dim x As Integer, y As Integer
    Do
    x = Int((Rnd * 100) + 1)
    y = Int((Rnd * 100) + 1)
    Debug.Print "x:" & x;
    Debug.Print " y:" & y;
    Debug.Print " x/y= " & x / y
    If x / y = Int(x / y) Then
    Debug.Print "x/y is Integer"
    Exit Do
    Else
    Debug.Print "x/y is not Integer"
    End If
    Loop
    End Sub

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
  •