Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code to Hide Excel 2010 Rows

Status
Not open for further replies.

mjd1947

IS-IT--Management
May 29, 2013
10
0
0
US
I need a macro that will hide an entire row in Excel 2010 based on the value in one column. I have found other macros but they perform very slowly with 2010. The sheet has about 1300 rows.

Thanks in advance.
 
A better place to ask this question would be VBA Visual Basic for Applications (Microsoft)
But, try this:

Column A:[tt]
Header
1
2
3
4
5
6
7
8
9
10
[/tt]

Code:
Dim i As Integer
i = 2
Do While Range("A" & i).Value <> ""
    If Range("A" & i).Value = "4" Then
        Rows(i & ":" & i).EntireRow.Hidden = True
    End If
    i = i + 1
Loop

Macro will hide the Row with the value 4


Have fun.

---- Andy
 
A filter is more likely to perform more quickly than using VBA, as mentioned by mintjulep.

Any reason you need to use VBA in this scneario?

If you want a filter, but want it automated, you can look into creating and managing List Objects and Query Tables in Excel VBA.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top