# Brief Question

#### jac3130

##### Board Regular
I have one column of data with various numbers. I'm in need of a macro that will hide every instance of the number 4 in a cell. If possible, please include a quick explanation of what each part of the macro is doing so I can better understand the VBA language. Thank you for your help.

### Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

#### kevin lazell

##### Well-known Member
hello jac3130
1. is it a column of single numbers and you want the row hidden or deleted that contains a 4
2. are there more than 1 number in each cell ie: 35423 and you want 3523 or 35-23 or -----
3. which column do you want this done to
cheers

kevin

#### Snakehips

##### Well-known Member
jac3130,

Maybe something like this.....

Assumes hiding rows that contain the discrete number 4 in column B.

Using AutoFilter

Code:
``````Sub Filter_4s()
'Assumes column to be column B
'Hides rows using AutoFilter
Range("B:B").AutoFilter Field:=1, Criteria1:="<>4"
End Sub

Sub UnFilter_4s()
'Assumes column to be column B
'Unhides rows
Range("B:B").AutoFilter
End Sub``````

Looping through range......

Code:
``````Sub Hide_4s()
'Assumes column to be column B
'Determine last row in B with data
LastRow = Range("B" & Rows.Count).End(xlUp).Row
'Define range to look at
Set MyRange = Range("B1:B" & LastRow)
'Loop through to find 4 and hide row
For Each Cell In MyRange
If Cell.Value = 4 Then Cell.Rows.Hidden = True
Next Cell
End Sub

Sub Show_4s()
'Unhide rows
'Assumes column to be column B
Range("B:B").Rows.Hidden = False
End Sub``````

Hope that helps

Replies
1
Views
166
Replies
2
Views
350
Replies
1
Views
76
Replies
11
Views
276
Replies
1
Views
212

1,195,702
Messages
6,011,200
Members
441,594
Latest member
AVO

### 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?

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