Beneindias
Board Regular
- Joined
- Jun 21, 2022
- Messages
- 120
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi guys,
I'm creating a file to calculate employees wage and taxes.
In order to avoid having a table with close to 80 columns, I'm looking at having a sheet to work like a resume with taxes and amount to transfer to the employee and have individual sheets where the calculations happen.
To build this, I looked at creating a table row from each sheet, but only found a solution to create sheets from table rows. I already have VBA code that can copy a template that I have, and change the name of the sheet to the employee name.
Now, my first problem is that after my sheets are created, I can't create new sheets when I update my "resume" table. Meaning that if I have a new employee and add is name to the end of the table, my code will not create a new sheet to this new name.
Other thing, I would like to update my code so that it look for a specific header in a table instead of a cell range as I have it now.
My code looks like this:
"Salários 1" is the sheet that I'm considering as a Template.
And another thing, in the "resume" table, I have cells that will take values from this new sheets. Is there any way that this formulas will automaticaly update to seek cells in the new sheet name?
Like, if I have a formula in my table that takes a value from the sheet named "Ana", but then I create a row and sheet called "Sara" I need that formula in the new row to update to the sheet called "Sara".
Is that possible?
Thanks for the help
I'm creating a file to calculate employees wage and taxes.
In order to avoid having a table with close to 80 columns, I'm looking at having a sheet to work like a resume with taxes and amount to transfer to the employee and have individual sheets where the calculations happen.
To build this, I looked at creating a table row from each sheet, but only found a solution to create sheets from table rows. I already have VBA code that can copy a template that I have, and change the name of the sheet to the employee name.
Now, my first problem is that after my sheets are created, I can't create new sheets when I update my "resume" table. Meaning that if I have a new employee and add is name to the end of the table, my code will not create a new sheet to this new name.
Other thing, I would like to update my code so that it look for a specific header in a table instead of a cell range as I have it now.
My code looks like this:
VBA Code:
Sub Rows_to_New_Sheet()
Dim A, W_S As Worksheet, LastRow
On Error Resume Next
LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For Each A In Range("B7:B" & LastRow)
If A.Value <> "" Then
Set W_S = Worksheets(A.Value)
If W_S Is Nothing Then
Sheets("Salários 1").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = Application.Proper(A.Value)
End If
End If
Next A
End Sub
"Salários 1" is the sheet that I'm considering as a Template.
And another thing, in the "resume" table, I have cells that will take values from this new sheets. Is there any way that this formulas will automaticaly update to seek cells in the new sheet name?
Like, if I have a formula in my table that takes a value from the sheet named "Ana", but then I create a row and sheet called "Sara" I need that formula in the new row to update to the sheet called "Sara".
Is that possible?
Thanks for the help