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 (excel vb message box)Next Topic (Populating a List Box) 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
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: excel vb message box

Are you referrring to your first MsgBox the one inside the initial test for "moo"? The textbox shouldn't be doing this unless it isn't really empty (""?)...

Maybe try this...


...
...
moo = LCase(Sheet5.TextBox1.Text)

b = 1
c = 1

If Len(moo) = 0 Then
   MsgBox "Please Key In a Value"
   Exit Sub
End If
...
...


____________________________
Eggheads unite! You have nothing to lose but your yolks.

03-06-2003 at 01:03 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mayanair
Level: Guest

icon Re: excel vb message box

im talking about the second message box...the first one works fine

04-06-2003 at 12:01 AM
| Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: excel vb message box

Check your data cause the If..Then looks OK...rather, it seems to work correctly for how its coded.

____________________________
Eggheads unite! You have nothing to lose but your yolks.

04-06-2003 at 01:02 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: excel vb message box

Check my reply at

http://www.andreavb.com/forum/viewtopic.php?TopicID=1463

  

____________________________
Real Programmer can count up to 1024 on his fingers

04-06-2003 at 01:16 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : excel vb message box
Previous Topic (excel vb message box)Next Topic (Populating a List Box) 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