PDA

View Full Version : [SOLVED] Hide rows between 2 strings



blackie42
12-21-2016, 07:42 AM
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

Logit
12-21-2016, 06:02 PM
How are you adding new rows to the yellow highlighted section ?

p45cal
12-21-2016, 06:08 PM
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.

blackie42
12-22-2016, 02:30 AM
@ 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