#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    29
    Rep Power
    0

    VB excel message box


    hmm...this time i need help with the message box. my code is as follows but i really dunno what is wrong with it....the message box pops out ok but the data displayed is not as what as i expected.

    Private Sub CommandButton1_Click()
    moo = LCase(Sheet5.TextBox1.Text)

    b = 1
    c = 1

    If Sheet5.TextBox1.Text = "" Then
    MsgBox "Please Key In a Value"
    Exit Sub
    End If

    For a = 9 To 500

    If LCase(Sheet3.Cells(a, 4)) = moo Then
    Sheet5.Cells(b + 7, 1) = Sheet3.Cells(a, 2)
    Sheet5.Cells(b + 7, 2) = Sheet3.Cells(a, 3)
    Sheet5.Cells(b + 7, 3) = Sheet3.Cells(a, 10)
    Sheet5.Cells(b + 7, 4) = Sheet3.Cells(a, 14)
    Sheet5.Cells(b + 7, 5) = Sheet3.Cells(a, 24)
    Sheet5.Cells(b + 7, 6) = Sheet3.Cells(a, 5)
    b = b + 1
    ElseIf LCase(Sheet2.Cells(a, 4)) = moo Then
    Sheet5.Cells(c + 7, 1) = Sheet2.Cells(a, 2)
    Sheet5.Cells(c + 7, 2) = Sheet2.Cells(a, 5)
    Sheet5.Cells(c + 7, 3) = Sheet2.Cells(a, 9)
    Sheet5.Cells(c + 7, 4) = Sheet2.Cells(a, 18)
    Sheet5.Cells(c + 7, 5) = Sheet2.Cells(a, 25)
    Sheet5.Cells(c + 7, 6) = Sheet2.Cells(a, 6)
    c = c + 1

    Exit Sub
    End If
    Next a
    MsgBox "Invalid"


    End Sub
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Melbourne, Australia
    Posts
    212
    Rep Power
    12
    Can you give some sample data, of what you are expecting to get, and what you actually get.
    How can I soar like an eagle when
    I'm flying with turkey's?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    29
    Rep Power
    0

    access


    its ok...coz eventually ive decided to use access instead...using excel is too risky as some functions that ive done like this is not able to handle many possible exceptions...

    anyway r u familiar with access?? would be a great help for me as im now in the process of learning access...

IMN logo majestic logo threadwatch logo seochat tools logo