Hello friends,
I have built a quite simple code, that is called upon pressing an object, which hides rows on one object:
And, a little line of code, that unhides rows:
This follows on the same worksheet, for 6 groups, like:
column A
5 CAFETARIA
6 Product 1c
7 Product 2c
8 Product 3c
9 Product 4c
10 Product 5c
11 Product 6c
12 BATATA FRITA
13 Product 1bf
14 Product 2bf
...
Being the cap words, the rows which have the products designation.
But then I needed to create a macro that allowed me to insert a line after the last product of each group, so I did this:
Now, I was in need of help for 2 problems...
First one is, when the line is inserted, it will bring down also, the last product of that group, for example in CAFETARIA group, instead of the last row being clear to fill in with a new product, product 6c would be the last row (12th one), being row 11 the one in blank. Another problem with this, is that I have to do a completely new code to hide the group rows, because by inserting new products, the current rows will change.
I am trying to find a way to hide and unhide the rows, by designating the first row to hide, the row below CAFETARIA text row, and the last row as the row above BATATA FRITA row, as an example.
Any help on this is greatly apreciated .
I have built a quite simple code, that is called upon pressing an object, which hides rows on one object:
Code:
Sub MINIMIZAR_CAFETARIA()
Rows("6:11").Hidden = True
End Sub
And, a little line of code, that unhides rows:
Code:
Sub MAXIMIZAR_CAFETARIA()
Rows("5:12").Hidden = False
End Sub
This follows on the same worksheet, for 6 groups, like:
column A
5 CAFETARIA
6 Product 1c
7 Product 2c
8 Product 3c
9 Product 4c
10 Product 5c
11 Product 6c
12 BATATA FRITA
13 Product 1bf
14 Product 2bf
...
Being the cap words, the rows which have the products designation.
But then I needed to create a macro that allowed me to insert a line after the last product of each group, so I did this:
Code:
Sub INSERT_CAFETARIA()
For a = 1 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
If ActiveSheet.Cells(a, 1).Value = "BATATA FRITA" Then
ActiveSheet.Rows(a - 1).Insert
a = a + 1
End If
Next a
End Sub
Now, I was in need of help for 2 problems...
First one is, when the line is inserted, it will bring down also, the last product of that group, for example in CAFETARIA group, instead of the last row being clear to fill in with a new product, product 6c would be the last row (12th one), being row 11 the one in blank. Another problem with this, is that I have to do a completely new code to hide the group rows, because by inserting new products, the current rows will change.
I am trying to find a way to hide and unhide the rows, by designating the first row to hide, the row below CAFETARIA text row, and the last row as the row above BATATA FRITA row, as an example.
Any help on this is greatly apreciated .