Solved

Run Macro When Cell Value = "X"

Posted on 2011-02-19
7
651 Views
Last Modified: 2012-05-11
When an "X" is entered in cell I13, I need it to trigger a macro that will unhide a specific row.  Macro name is "Unhide1"

Thanks
0
Comment
Question by:klitton7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 45

Accepted Solution

by:
patrickab earned 50 total points
ID: 34934606
klitton7,

The code below is in the attached file. Place an x in I13 and it will unhide row 10.

Patrick
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

Set rng = Me.Cells(13, "I")

If Not Intersect(rng, Target) Is Nothing Then
    If LCase(Target.Value) = "x" Then
        Rows("9:11").EntireRow.Hidden = False
    End If
End If

End Sub

Open in new window

Unhide-row-01.xls
0
 
LVL 1

Expert Comment

by:dev00790
ID: 34934675
This will unhide the 1st row when a user open the file, providing the cell specified has an "X", and that the 1st row is already hidden.

 
Option Explicit
Public rownum As Integer

'Row 1 must be hidden when opening file for below to work
'An "X" must be in the cell specified also when opening file.

Sub auto_open()

    rownum = 1
    
    If Cells(13, 9).Value = "X" Then
        Rows(rownum).EntireRow.Hidden = False
    Else
        'Put what you want to happen when cells(13,9) value is not "X" here
    End If

End Sub

Open in new window


Regards
Unhide-row.xls
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34934869
dev00790,

What worksheet is that supposed to work as you haven't specified it.

Patrick
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Expert Comment

by:dev00790
ID: 34935133
it's "sheet1"

dev00790
0
 

Author Closing Comment

by:klitton7
ID: 34935374
This worked great (no need to trigger a macro -
 I need to add to 7 other cells:
I15 unhide 16
I17 unhide 18
I20 unhide 21
J23 unhide 24
J25 unhide 26
J30 unhide 31
J32 unhide 33
Not sure how to do this - should I enter a new question to get this answerr?
0
 
LVL 1

Expert Comment

by:dev00790
ID: 34935468
You will need to ask a new question for that klitton7.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34936675
klitton7 - Thanks for the grade - Patrick
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question