Solved

Run Macro When Cell Value = "X"

Posted on 2011-02-19
7
639 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
  • 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now