Excel Macro - hiding rows

imgcfimgcf

New member
Local time
Today, 12:12
Joined
May 11, 2009
Messages
1
Hi,

I need help writing a macro that hides rows based on info in the Column B cells.

For example, I'd like to hide rows if the Column B cells contain combination of letters "MGM" or "BUYER"... The thing is the cells contain other letters or numbers as well.

Below are just a few examples Column B cells that I'd like to hide.

MGM 1120 suits
MGM 1130 clothing
MGM 1140 pants
BUYER 120 suits
BUYER 124 bottoms
BUYER 435 belts

thanks....
 
You need to test for the strings with wildcard characters. Using MyCell as a placeholder for however you're selecting the Column B cells, I think you'll want something like:

If MyCell.Value Like "MGM*" Or MyCell.Value Like "BUYER*" Then
...
End If

This will pick up all cells that start with the letters MGM or BUYER (not case sensitive).

[edit]
Oops, sorry, just realised this is the Macros board, thought I was in Modules! Anyway, I think using Like and the * wildcard character are still correct, just adapt the syntax to fit a macro rather than code.
[/edit]
 
Last edited:

Users who are viewing this thread

Back
Top Bottom