Hiding rows based on user input

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help fixing the following code. Basically, if the user answers "no",
then I want to hide all of the rows in the worksheet that have a "v" in
column "A". I'm new to VBA but am learning thanks to everyone's help.

Thanks!

Randy

Select Case ProjectSize
Case Is = "l", "m"
resp = MsgBox("Will a vendor be used for this project?",
vbYesNo)

If resp = vbYes Then
vendor = ""
Else
vendor = "v"
For Each row In ActiveSheet.UsedRange.Rows
If row.cell = vendor Then
row.Hidden = True
End If
Next row

End If


End Select
 
try this. modify range to suit

Sub hidevendor()
Rows.Hidden = False
ans = MsgBox("will a vendor be used", vbYesNo)
If ans = vbNo Then ' MsgBox "hi"
For Each c In Range("a2:a23")
If c = "v" Then c.EntireRow.Hidden = True
Next c
End If
End Sub
 

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

Back
Top