+ Reply to Thread
Results 1 to 6 of 6

Can I create an If condition with multiple Then (consequences) ?

  1. #1
    Registered User
    Join Date
    08-27-2014
    Location
    Lisboa, Portugal
    MS-Off Ver
    2007
    Posts
    24

    Exclamation Can I create an If condition with multiple Then (consequences) ?

    So the title is pretty self explanatory but... Is it possible for me to create a code in my worksheet with an If condition with several Then statements?
    Kind of like what I am trying to do here... (code is in a worksheet called CAPA)
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = Me.Range("G9").Address Then
    If Target.Value = "" Then
    Sheets("%Humidade NLT 102 91").Visible = False
    Sheets("RESUMO").Column("9").Visible = False
    Else
    Sheets("%Humidade NLT 102 91").Visible = True
    Sheets("RESUMO").Column("9").Visible = True
    End If
    End If

    But it bugs on the Sheets("RESUMO").Column("9").Visible = False part, saying ''Object doesn't support this property or method"
    Helppppp

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Can I create an If condition with multiple Then (consequences) ?

    Actually The column property returns the column Num not the column itself..
    You have to use columns property... to refer a column...

    and for multiple conditions use AND and OR statements..

    here is the revised code..

    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  3. #3
    Registered User
    Join Date
    08-27-2014
    Location
    Lisboa, Portugal
    MS-Off Ver
    2007
    Posts
    24

    Re: Can I create an If condition with multiple Then (consequences) ?

    Thank you but I tried your code and it bugs, the pop up says "aplication defined or object defined error"...
    Quote Originally Posted by Vikas_Gautam View Post
    Actually The column property returns the column Num not the column itself..
    You have to use columns property... to refer a column...

    and for multiple conditions use AND and OR statements..

    here is the revised code..

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Can I create an If condition with multiple Then (consequences) ?

    On which line it bugged..?

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Can I create an If condition with multiple Then (consequences) ?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Can I create an If condition with multiple Then (consequences) ?

    Yeah Johnson Sir..

    and moreover OP has not provided any workbook to work with...
    so its like aiming in the night..

+ 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. Using the IF function with non-numeric digits & with numeric consequences
    By oldmillbill in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-08-2012, 02:39 PM
  2. Replies: 6
    Last Post: 05-06-2010, 10:06 PM
  3. how do you create a double condition in excel
    By Love Excel in forum Excel General
    Replies: 4
    Last Post: 07-04-2009, 09:04 PM
  4. Create an Automatic Pop-up Based on a Condition
    By chelseasikoebs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2009, 03:09 AM
  5. create condition formula
    By kjcramp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-11-2008, 02:53 PM

Tags for this Thread

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