Ben Jansen
New Member
- Joined
- Jun 12, 2020
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Hi All,
getting into the VBA programming and already managed to make my life a lot easier with some simple coding. This thing is cool to learn!
Now I am trying to level up and make my programming a bit more clean and professional by using NAMED RANGES.
My intention :
in my template I will have a named range with multiple rows and columns.
along the way I might add rows, so the amount of rows is not necessarily static.
I want VBA to loop through a certain Named Range and take action when a certain cell is or isn't filled out
(more specific, if it is not filled out, it should hide the row... Kind of a "clean-up my form code")
So in my head it is like :
'go to first line of named range
'check if column O and P is filled out
' - if it is filled out , go to the next range line
' - if it is not filled out, hide that row and go to the next line
'do this for the whole range
I am working with something similar to below now (VBA beginner code), but as soon as I insert some rows my code is screwed.
(And i have many many ranges programmed)
Any ideas would be appreciated !
getting into the VBA programming and already managed to make my life a lot easier with some simple coding. This thing is cool to learn!
Now I am trying to level up and make my programming a bit more clean and professional by using NAMED RANGES.
My intention :
in my template I will have a named range with multiple rows and columns.
along the way I might add rows, so the amount of rows is not necessarily static.
I want VBA to loop through a certain Named Range and take action when a certain cell is or isn't filled out
(more specific, if it is not filled out, it should hide the row... Kind of a "clean-up my form code")
So in my head it is like :
'go to first line of named range
'check if column O and P is filled out
' - if it is filled out , go to the next range line
' - if it is not filled out, hide that row and go to the next line
'do this for the whole range
I am working with something similar to below now (VBA beginner code), but as soon as I insert some rows my code is screwed.
(And i have many many ranges programmed)
Any ideas would be appreciated !
VBA Code:
Sub Button3_Click()
For a = 70 To 75
'Hide all Cells where nothing is filled out in column O and P
'under section Mech Pos Indication
If Worksheets("Valve REPORT").Cells(a, 15).Value = "" And Worksheets("Valve REPORT").Cells(a, 16).Value = "" Then
Worksheets("Valve REPORT").Rows(a).Hidden = True
End If
End sub
Next