+ Reply to Thread
Results 1 to 4 of 4

If statement use with several and

  1. #1
    Registered User
    Join Date
    12-16-2014
    Location
    Sherbrooke, Canada
    MS-Off Ver
    Professionnel Plus 2010
    Posts
    0

    If statement use with several and

    Hi guys,
    I'm trying to wrote a message in a textbox, with this macro;

    Sub TextBox()
    If (A36 = 1) And (B36 = 1) And (C36 = 1) And (D36 = 1) And (E36 = 1) And (F36 = 1) And (G36 = 1) And (H36 = 1) And (J36 = 1) Then
    TextBox.Text = "3RT20-1AB01"
    End If
    End Sub

    when I validated my entery it said; compilation error (Function or awaiting variable)???
    His anyone know what i'm missing or doing wrong, I have to say that I would like to add a lot OR IF statement after this one will be solve.

    Thank you to every one.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello Buddypaint,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-01-2009
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    0

    Re: If statement use with several and

    Hi Buddypaint,

    You have the incorrect syntax, try this:
    Sub Msg_Box()
    If Range("A36").Value = 1 And Range("B36").Value = 1 Then
    MsgBox "3RT20-1AB01"
    End If
    End Sub

    NOTE: You cannot use the MsgBox as the name of the subroutine since it is one of the reserved words. Hence, I change it from MsgBox to Msg_Box.

    thanks,
    Lawrence

  4. #4
    Registered User
    Join Date
    12-26-2013
    Location
    CDA, ID
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: If statement use with several and

    I was looking at your file and I cannot find a declared text box. Have you created a text box on one of the worksheets?

    LB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  2. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  3. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  4. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  5. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1