View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
MSP77079[_53_] MSP77079[_53_] is offline
external usenet poster
 
Posts: 1
Default parameter queries in macros

Try this:

Sub hidecolumns()
Columns("d:fz").Hidden = False
Dim sPrompt As String
sPrompt = "Enter 1 for Initial DHS Recommendation" & vbNewLine & "Ente
2 for Project Recommendation" & vbNewLine & "Enter 3 for Final DH
Recommendation" & vbNewLine & "Enter 4 for Project/DHS Matches"
vbNewLine & "Enter 5 for DHS VDAT Modules"
x = InputBox(sPrompt)
Set myRange = Range("A1").CurrentRegion
LastRow = myRange.Cells(myRange.Cells.Count).Row
For Each c In Range("d1:fz1")
If Right(c, 1) < x Then
c.EntireColumn.Hidden = True
Else:
Hide = True
j = c.Column
For i = 2 To LastRow
If Cells(i, j) = "D" Then Hide = False
Next i
If Hide Then c.EntireColumn.Hidden = True
End If
Next
End Su

--
Message posted from http://www.ExcelForum.com