VBA to hide rows

andy_2610

Board Regular
Joined
Jan 29, 2015
Messages
168
Hi all,

I need help with a vba code to hide rows based on certain criteria. I have a large range of data. Column A is the dependent to hiding the entire row.
For an example below:

ABCDE
1Invoiced10apples
2Paid10oranges
3Enroute20bananas
4Delivered15avocados
5Invoiced20watermelon
6Completed30Coffee

<tbody>
</tbody>

If Column A = "Invoiced", "Paid", or "Completed" then I want the entire row hidden. So in this case, row 1, 2, 5, and 6 should be hidden.

Thanks in advance,

Andrew
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello Andy,

Try this code in a standard module:-


Code:
Sub HideRows()

Dim lRow As Long
lRow = Range("A" & Rows.Count).End(xlUp).Row

For Each cell In Range("A1:A" & lRow)
     If cell = "Invoiced" Or cell = "Paid" Or cell = "Completed" Then
     cell.EntireRow.Hidden = True
     End If
Next

End Sub

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0
Hi Andy,

Glad that I could help.

Cheerio,
vcoolio. :)
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top