Hi I am trying to create a form where different a different subject may be chosen and depending on which one, certain questions need to be asked but this is required across two separate “forms” which I have set up as “worksheet”. However, I can only seem to hide the rows I don’t want on both sheets by running two separate Macros – is there a way to just run one Macro but which hides the rows across both sheets>
What I have at present is:
Workbook “Initial Assessment” – where Cell E1 changes depending on the subject.
Sub HideRowCellNumValue()
StartRow = 81
LastRow = 556
iCol = 1
For i = StartRow To LastRow
If Cells(i, iCol).Value = Range("G1").Value Then
Cells(i, iCol).EntireRow.Hidden = False
Else
Cells(i, iCol).EntireRow.Hidden = True
End If
Next i
End Sub
When run, this Macro hides any row between 81 – 556 where Column 1 (column A on the Sheet) does not contain the name of the subject in Cell E1
I have a second sheet in this workbook (Tab4 - Plan of Training) which I want to link to the subject in “E1” on the Initial Assessment sheet and likewise hide certain rows depending on the subject (rows 81 – 556).
However the only way I have managed it is to run a separate Macro (sort of replicating the first but changed for the applicable rows)
Sub HideRowCellNumValue()
StartRow = 81
LastRow = 556
iCol = 1
For i = StartRow To LastRow
If Cells(i, iCol).Value = Range("G1").Value Then
Cells(i, iCol).EntireRow.Hidden = False
Else
Cells(i, iCol).EntireRow.Hidden = True
End If
Next i
End Sub
Is there a way to hide the applicable rows in the second sheet based on the selection in the first with only one macro needed to be run?
Thanks
What I have at present is:
Workbook “Initial Assessment” – where Cell E1 changes depending on the subject.
Sub HideRowCellNumValue()
StartRow = 81
LastRow = 556
iCol = 1
For i = StartRow To LastRow
If Cells(i, iCol).Value = Range("G1").Value Then
Cells(i, iCol).EntireRow.Hidden = False
Else
Cells(i, iCol).EntireRow.Hidden = True
End If
Next i
End Sub
When run, this Macro hides any row between 81 – 556 where Column 1 (column A on the Sheet) does not contain the name of the subject in Cell E1
I have a second sheet in this workbook (Tab4 - Plan of Training) which I want to link to the subject in “E1” on the Initial Assessment sheet and likewise hide certain rows depending on the subject (rows 81 – 556).
However the only way I have managed it is to run a separate Macro (sort of replicating the first but changed for the applicable rows)
Sub HideRowCellNumValue()
StartRow = 81
LastRow = 556
iCol = 1
For i = StartRow To LastRow
If Cells(i, iCol).Value = Range("G1").Value Then
Cells(i, iCol).EntireRow.Hidden = False
Else
Cells(i, iCol).EntireRow.Hidden = True
End If
Next i
End Sub
Is there a way to hide the applicable rows in the second sheet based on the selection in the first with only one macro needed to be run?
Thanks