Solved

Run Macro When Cell Value = "X"

Posted on 2011-02-19
7
655 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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