Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I want to make rows 24, 25, & 28 not visible if cell b7+f7+j7=0 what is the best way to do this? I think I can incorporate into an existing macro but I don't know how to write the code... I thought it would it be close to this but I keep getting a syntax error

    IF wsh.Range("a24").Value = "0" AND wsh.Range("d24").Value = "0" AND wsh.Range("g24").Value = "0" Then wsh.Range("A24:A25").EntireRow.Hidden = true AND wsh.Rows(28).Hidden = True

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Your code uses different conditions from what you describe, but apart from that, you should be able to use

    Code:
    If wsh.Range("A24").Value = "0" And wsh.Range("D24").Value = "0" AND wsh.Range("G24").Value = "0" Then
      wsh.Range("A24:A25").EntireRow.Hidden = True
      wsh.Rows(28).Hidden = True
    End If

  3. #3
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Hans, it works perectly. How do you make the line break in the VBA window? When I hit enter to go to the next line, I get a compile error: Expected: expression

    [quote name='HansV' post='782783' date='02-Jul-2009 11:41']Your code uses different conditions from what you describe, but apart from that, you should be able to use

    Code:
    If wsh.Range("A24").Value = "0" And wsh.Range("D24").Value = "0" AND wsh.Range("G24").Value = "0" Then
      wsh.Range("A24:A25").EntireRow.Hidden = True
      wsh.Rows(28).Hidden = True
    End If
    [/quote]

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you want to break a line in Visual Basic code, type a space and an underscore at the place where you want the break, then press Enter. For example:

    Code:
    If wsh.Range("A24").Value = "0" And wsh.Range("D24").Value = "0" _
      And wsh.Range("G24").Value = "0" Then

  5. #5
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you - makes it easier to write & read (but not necessarily understand) the code.

    [quote name='HansV' post='782789' date='02-Jul-2009 11:54']If you want to break a line in Visual Basic code, type a space and an underscore at the place where you want the break, then press Enter. For example:

    Code:
    If wsh.Range("A24").Value = "0" And wsh.Range("D24").Value = "0" _
      And wsh.Range("G24").Value = "0" Then
    [/quote]

Posting Permissions

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