I have a worksheet in which the cell in column B of the membership list contains a 'Y' or a 'N', depending on whether someone is a member or not.
I want to write a macro, whereby, on clicking the macro button, only rows with a 'Y' will show. Rows with a 'N' will be hidden.
Any help appreciated.
Hi BazzaBoy
I'd think you may need two buttons. See attached.
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Thanks jaslake,
I am a non-programmer. So, I only know how to work with simple macros. Can you show me how you have connected the command buttons to the VBA code?
I already have the following code under sheet1:
Private Sub Worksheet_Change(ByVal Target As Range) Dim TestRangeString As String If Target.Cells.Count > 1 Then Exit Sub End If On Error GoTo ErrHandler: TestRangeString = "B8:B100,G8:J100" If Not Application.Intersect(Range(TestRangeString), Target) Is Nothing Then If IsNumeric(Target.Value) = False Then Application.EnableEvents = False 'Target.Value = StrConv(Target.Text, vbLowerCase) Target.Value = StrConv(Target.Text, vbUpperCase) 'Target.Value = StrConv(Target.Text, vbProperCase) Application.EnableEvents = True End If End If ErrHandler: Application.EnableEvents = True Dim TestRangeString2 As String If Target.Cells.Count > 1 Then Exit Sub End If On Error GoTo ErrHandler2: TestRangeString2 = "C8:C100,D8:D100,E8:E100" If Not Application.Intersect(Range(TestRangeString2), Target) Is Nothing Then If IsNumeric(Target.Value) = False Then Application.EnableEvents = False 'Target.Value = StrConv(Target.Text, vbLowerCase) 'Target.Value = StrConv(Target.Text, vbUpperCase) Target.Value = StrConv(Target.Text, vbProperCase) Application.EnableEvents = True End If End If ErrHandler2: Application.EnableEvents = True End Sub
Can we not just do it with sinple macros and macro buttons?
Thanks.
The code you have displayed goes into the worksheet module not a regular module, you cannot attach a button to a worksheet module.
Right click on the sheet tab and select view code, copy and paste the code there. When there is a change in "B8:B100,G8:J100"
The code will activate.
Hi BazzaBoy
The code I provided in the attached workbook does thisIf you need something further, you'll need to describe/show what it is you need to do.on clicking the macro button, only rows with a 'Y' will show. Rows with a 'N' will be hidden
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Thanks davesexcel ,
All sorted out.
You may mark this thread as SOLVED.
Must be late. I'm a little confused.
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks