borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Combobox)Next Topic (List Box Scripting Problems) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : excel vb message box
Poster Message
mayanair
Level: Guest


icon excel vb message box

could u please help me with ths coding here...i seem to get it rite but the logic of where to put the message box is totally wrong...it pops out even when the data is available in the worksheet......thanx


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 20

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
    
    ElseIf (LCase(Sheet3.Cells(a, 4)) <> moo And LCase(Sheet2.Cells(a, 4)) <> moo) Then
    MsgBox "Invalid"
    End If
      
Next a

End Sub  

03-06-2003 at 05:30 AM
| Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : excel vb message box
Previous Topic (Combobox)Next Topic (List Box Scripting Problems) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder