Text Box value to hide a row in another worksheet

G

Guest

I am trying to use a TextBox value to determine if a row on another
spreadsheet should be visible or not. I have the following:

Private Sub Worksheet_Change(ByVal Target As Range)

If Worksheets("Input Page").TB21.Value = 0 Then
Worksheets("Summary Report").Rows(19).EntireRow.Hidden = True
Else
Worksheets("Summary Report").Rows(19).EntireRow.Hidden = False
End If
End Sub

It works if I manually override the value in the TextBox's linked cell; say
AC49, but will not if I simply change the value in the TextBox itself like I
would like the user to do.

Any suggestions?
 
G

Guest

hi,
The reason it doesn't work is because you are using the worksheet change
event.
this doesn't work on text boxes. in stead put the code in the text box
change event.
chick design>right click text box>select view code.

Private Sub TextBox1_Change()
If Worksheets("Sheet1").TextBox1.Value = 0 Then
Worksheets("Sheet2").Rows(19).EntireRow.Hidden = True
Else
Worksheets("Sheet2").Rows(19).EntireRow.Hidden = False
End If
End Sub

worked for me. i'm using xl

Regards
FSt1
 
G

Guest

THANK YOU FSt1. You don't know how long I have been trying to figure that
out and been looking at the round end. The fix was actually too easy once
you showed it to me. Again, thank you.
 
G

Guest

How can I change the following to hide the row if the textbox is blank or zero?

Private Sub TextBox21_Change()
If Worksheets("Input Page").TextBox21.Value = 0 Then
Worksheets("Summary Report").Rows(19).EntireRow.Hidden = True
Else
Worksheets("Summary Report").Rows(19).EntireRow.Hidden = False
End If
End Sub
 
G

Guest

hi,
just add another if. something like this...
Private Sub TextBox1_Change()
If Worksheets("Sheet1").TextBox1.Value = 0 Then
Worksheets("Sheet2").Rows(19).EntireRow.Hidden = True
Else
If Worksheets("sheet1").TextBox1.Value = "" Then
Worksheets("Sheet2").Rows(19).EntireRow.Hidden = True
Else
Worksheets("Sheet2").Rows(19).EntireRow.Hidden = False
End If
End If
End Sub

worked for me. i'm using xp.
regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top