+ Reply to Thread
Results 1 to 2 of 2

If statement needs to perform (2) two actions

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    United States
    MS-Off Ver
    2010
    Posts
    12

    Question If statement needs to perform (2) two actions

    The code below works great but I realized I have an issue that needs to be accounted for. If the cells in range "J9:J378" are false I want to hide those rows. This part works great. The true and false are set in each cell in column "J" based on a userform checkbox. The problem is I need to eliminate (set to empty) a quantity in range A9:A378 based on the cells in Range J9:J378 that are being hidden due to the value being False. The problem arises when the userform is reopened and the checkbox is unselected while quantities have been assigned prior to unclicking the checkbox. It still adds to all the totals in the estimation worksheet creating false labor time and material cost based on the quantities that are unneeded in column "A".

    So what I want to do is

    If any cells in range J9:J378 are false, hide all rows and change any values in A9:A378 to empty as long as they are the same cells with a value of false.

    Thank you for any help in advance, this forum has been a great resource for me through my journey of learning VBA.

    Public Sub AcceptButton_Click()
    
    Dim cell As Range
    Application.ScreenUpdating = False
        For Each cell In Range("J9:J378")
            If cell.Value = "False" Then
                cell.EntireRow.Hidden = True
            Else
                cell.EntireRow.Hidden = False
            End If
            Next
    Application.ScreenUpdating = True
    
    Application.ScreenUpdating = False
        For Each cell In Range("J385:J1666")
            If cell.Value = "False" Then
                cell.EntireRow.Hidden = True
            Else
                cell.EntireRow.Hidden = False
            End If
            Next
    Application.ScreenUpdating = True
    
    Me.Hide
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: If statement needs to perform (2) two actions

    Couldn't you use SUMIF for the totals so they only include values from A where the value in J isn't False?
    If posting code please use code tags, see here.

+ 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. VBA excel coding to perform actions in IE
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2013, 12:57 PM
  2. Excel 2007 : Perform actions with filtered list
    By GaidenFocus in forum Excel General
    Replies: 5
    Last Post: 02-09-2011, 03:29 PM
  3. Perform various actions before exiting
    By Flaguette in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-14-2007, 07:20 AM
  4. How to perform two actions ?
    By morph000 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-21-2006, 10:20 PM
  5. [SOLVED] perform multiple actions in an IF
    By Gixxer_J_97 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-06-2005, 09:06 AM

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