I am making an accounting project. I have a formula that copies a template worksheet and renames it to the name of the account I just added The code is below. It also puts the name of the sheet in the next available line in my trial balance. I created a formula within the debit side of the cell and and the credit side of the cell to find the balance on the account sheet and put it in the trial balance. Here it is:
=IF(SUM(Cash!E4:E49)>SUM(Cash!D4:D49),SUM(Cash!E4:E49)-SUM(Cash!D4:D49), " ")
Is there a way I can use this formula to be put automatically in the next empty debit and credit cell so I don't have to manually put it in? Basically can I put it in with this code. Also it should take the name of the new account so it shows the appropriate balance.
Sub addacctandworksheet()
nextRow = 4
Do Until Sheets("Trial Balance").Cells(nextRow, 2).Value = Empty
nextRow = nextRow + 1
Loop
Sheets("Account Template").Visible = False
Worksheets("Account Template").Copy After:=Worksheets("Journal")
Sheets(2).Name = frmAddAcct.lbxAccts.Value
Sheets(2).Cells(2, 2).Value = frmAddAcct.lbxAccts
Sheets(2).Visible = True
Sheets("Trial Balance").Cells(nextRow, 2).Value = frmAddAcct.lbxAccts.Value
End Sub
=IF(SUM(Cash!E4:E49)>SUM(Cash!D4:D49),SUM(Cash!E4:E49)-SUM(Cash!D4:D49), " ")
Is there a way I can use this formula to be put automatically in the next empty debit and credit cell so I don't have to manually put it in? Basically can I put it in with this code. Also it should take the name of the new account so it shows the appropriate balance.
Sub addacctandworksheet()
nextRow = 4
Do Until Sheets("Trial Balance").Cells(nextRow, 2).Value = Empty
nextRow = nextRow + 1
Loop
Sheets("Account Template").Visible = False
Worksheets("Account Template").Copy After:=Worksheets("Journal")
Sheets(2).Name = frmAddAcct.lbxAccts.Value
Sheets(2).Cells(2, 2).Value = frmAddAcct.lbxAccts
Sheets(2).Visible = True
Sheets("Trial Balance").Cells(nextRow, 2).Value = frmAddAcct.lbxAccts.Value
End Sub