ClintMc
New Member
- Joined
- Dec 4, 2017
- Messages
- 4
Hey Guys & Gals -- Creating a template for Program Management and trying to add some VBA. New to VBA and what I thought would be straightforward is of course giving me a challenge.
I am sure it is a newbie thing I am missing but any help is much appreciated!
- taskRange = all the potential rows in the chart, would like to hide based on user input (currently 1 column with 100 rows in it and values consisting of 1-100)
- numOfTasks = user input cell telling the program how many tasks they would like to have for this project
- Getting a compile error on the IF/THEN statement saying "Expression Expected"
- The rest should be evident from the code I am hoping
Code:
Sub UserSelectsNumOfTasks()
'
' This code will run when user changes number of tasks on the worksheet
'
Dim WorkRng As Range
Dim Rng As Range
Dim numTasks As Integer
' MsgBox "You changed the number of tasks"
' setting the active range as the range of all the tasks
Set WorkRng = Range("taskRange")
numTasks = Range("numOfTasks").Value
' MsgBox WorkRng.Address
' MsgBox numTasks
' this for loop should go through all the rows in the range and hide
' the rows whose value is larger than user selected value
For Each Rng In WorkRng
If Rng.Value > numTasks Then
Rng.EntireRow.Hidden = True
End If
Next Rng
End Sub
I am sure it is a newbie thing I am missing but any help is much appreciated!