Results 1 to 4 of 4

VBA .Find Not Working with Formula

Threaded View

thejg89 VBA .Find Not Working with... 04-17-2019, 04:51 PM
KOKOSEK Re: VBA .Find Not Working... 04-17-2019, 04:57 PM
thejg89 Re: VBA .Find Not Working... 04-18-2019, 08:35 AM
Fluff13 Re: VBA .Find Not Working... 04-18-2019, 11:39 AM
  1. #1
    Registered User
    Join Date
    04-17-2019
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2013
    Posts
    3

    Smile VBA .Find Not Working with Formula

    Hello,

    I'm working on a dynamic valuation model with 80+ worksheets. The 'Settings' worksheet has numerous check boxes to determine which sheets need to be visible or hidden. Within in sheet, there are rows that only need to be shown if the corresponding account detail 'sheet' is visible and a column that will alert the user if they need to 'HIDE' the row.

    For example: lets assume on a Balance Sheet it lists 'vehicles and cars' as a row but if the 'vehicles and cars' detail sheet is hidden there would be an indicator on the Balance Sheet to 'HIDE' this row as it is not used in the analysis. Hopefully that helps explain the functionality.

    I have the code working for 'hardcoded' cell that = "HIDE" but it doesnt work if 'HIDE' is the result of an IF Statement (continuing the example ... one the column that indicates if a row needs to be hidden would have an equation something like =if( settings sheet checkbox for 'cars/vehicles' = checked, 'blank', 'HIDE').

    I've included an excel sheet, over simplified, but it should show the general understanding. The code was under a module but i moved it to ThisWorksheet. Below is also a copy of the code with comments as to what I was trying to accomplish

    This is my first post - so THANK YOU!!!! everyone who tries to help

    Sub toggleHide()
    
        Dim Sh As Worksheet, rnCheck As Range, rnFind As Range, stAddress As String
        
        Application.ScreenUpdating = False ' dont update screen till end
        
        For Each Sh In ThisWorkbook.Worksheets ' numerous sheets either active / in active based off settings
        
            If Sh.Visible = xlSheetVisible Then ' only run for visible sheets to keep macro fast
            
                Sh.Outline.ShowLevels RowLevels:=1, ColumnLevels:=1 'collapse all groups bc they dont need to be seen
                
                Set rnCheck = Sh.UsedRange.SpecialCells(xlCellTypeConstants) 'dynamically find the usedRange as it changes sheet to sheet
                
                With rnCheck
                    Set rnFind = .Find(What:="HIDE") 'THIS IS THE PROBLEM - it will work if text in the cell = 'HIDE' but not if its a result of an if statment
                    
                    If Not rnFind Is Nothing Then
                        stAddress = rnFind.Address
                Do
                    rnFind.EntireRow.Hidden = Not Range("Status").Value
                    Set rnFind = .FindNext(rnFind)
                Loop While Not rnFind Is Nothing And rnFind.Address <> stAddress
                
                    End If
            
                 End With
            
            End If
            
        Next Sh
    
        Application.ScreenUpdating = True
        
        Range("Status") = Not Range("Status") 'toggles hide / unhide rows in case a user wants to see all rows
        
    End Sub
    Last edited by thejg89; 05-02-2019 at 02:52 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formula Stopped Working (Sum if using left, find, len)
    By pmw19800 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-16-2019, 08:13 AM
  2. [SOLVED] Working on formula to find max values from different columns
    By weaverswonders6 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-04-2017, 01:36 PM
  3. Index Formula to find Multiple Values not working
    By cost9170 in forum Excel General
    Replies: 4
    Last Post: 03-18-2016, 04:35 PM
  4. RIGHT/FIND Formula Not Working
    By alanwu07 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-05-2013, 09:52 PM
  5. Replies: 14
    Last Post: 10-25-2012, 10:33 AM
  6. [SOLVED] My If(Find) Formula is not working!
    By becow13 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-17-2012, 02:46 PM
  7. Replies: 2
    Last Post: 05-15-2006, 02:35 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