Consulting

Results 1 to 4 of 4

Thread: Hide rows between 2 strings

  1. #1

    Hide rows between 2 strings

    Hi

    On sheet called 'Bank transactions' in cell B7 (static) I have the words 'Bank transactions'

    Row 8 is blank

    Row 9 has narrative 'Date' in A, 'Narrative' in B & 'Value in C' - don't need to see row 8 or 9

    I'd like to be able to hide these rows up to where column B has 'Uncleared Bank transactions'

    This will vary depending on the number of transactions appearing between B7 and B? (i.e. wherever 'Uncleared Bank Transactions' appears)

    Please see attached - need to highlight yellow area which varies each day - highlight one row too much as needs to still say
    Uncleared Bank Transactions with cheques and other uncleared items listed

    Any help very much appreciated

    thanks
    Jon
    Attached Files Attached Files

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    How are you adding new rows to the yellow highlighted section ?

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Set tr = Columns(2).Find(what:="Bank Transactions", LookIn:=xlFormulas, lookat:=xlWhole, searchformat:=False)
    Set br = Columns(2).Find(what:="Uncleared Bank Transactions", LookIn:=xlFormulas, lookat:=xlWhole, searchformat:=False)
    'Range(tr, br).EntireRow.Hidden = True
    Range(tr, br.Offset(-1)).EntireRow.Hidden = True 'doesn't hide the row Uncleared Transactions.
    'Range(tr, br).EntireRow.Hidden = Not (Range(tr, br).EntireRow.Hidden) 'toggles hidden/unhidden
    Play around with ONE of the last three statements.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    @ Logit - the yellow highlighted area is variable dependent on the number of transactions

    Only interested in the uncleared transactions.

    Thanks P45 - will have a play around . I was going to use a find (tr) and then offset step back with loop (until I found the br) deleting rows
    but since I only really have a basic knowledge of VBA probably would struggle to get the code in the right order.


    Update - no need to play around = the code works fine as is - thanks again.

    regards
    Jon

Posting Permissions

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