• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 671
  • Last Modified:

Run Macro When Cell Value = "X"

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
klitton7
Asked:
klitton7
  • 3
  • 3
1 Solution
 
patrickabCommented:
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
 
dev00790Commented:
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
 
patrickabCommented:
dev00790,

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

Patrick
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
dev00790Commented:
it's "sheet1"

dev00790
0
 
klitton7Author Commented:
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
 
dev00790Commented:
You will need to ask a new question for that klitton7.
0
 
patrickabCommented:
klitton7 - Thanks for the grade - Patrick
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now