Hello,
I've been trying different pieces of code to figure this one out but to no avail. I have a listbox on a form that populates when users select an option button. When they select something from the listbox and click ok the code makes a copy of a template sheet and places in workbook. It also renames the sheet with the name of the selected item in the listbox. Last it takes the same name selected in the listbox and adds it to the next empty spot on a sheet called "Main" (Column B).
All of this works fine except I need one final piece to the code for everything to work. The idea would be an "if" statement but I'm unsure exactly how?
If the sum of D4:D75 is greater than the sum of E4:E75 of the same sheet that is created and named. I would like to subtract the sum of E4:E75 from the sum of D4:D75 and place that answer on the current row of main sheet in the D column.
Else subtract the sum of E4:E75 from the sum of D4:D75 and place that answer on the current row of the main sheet in the E column? Is this possible??
Sheets("Main").Cells(curRow, 4).Formula = Sum(Sheets(Me.lbxAccount.Value).Range("E4:E75"))
I've been trying different pieces of code to figure this one out but to no avail. I have a listbox on a form that populates when users select an option button. When they select something from the listbox and click ok the code makes a copy of a template sheet and places in workbook. It also renames the sheet with the name of the selected item in the listbox. Last it takes the same name selected in the listbox and adds it to the next empty spot on a sheet called "Main" (Column B).
All of this works fine except I need one final piece to the code for everything to work. The idea would be an "if" statement but I'm unsure exactly how?
If the sum of D4:D75 is greater than the sum of E4:E75 of the same sheet that is created and named. I would like to subtract the sum of E4:E75 from the sum of D4:D75 and place that answer on the current row of main sheet in the D column.
Else subtract the sum of E4:E75 from the sum of D4:D75 and place that answer on the current row of the main sheet in the E column? Is this possible??
Sheets("Main").Cells(curRow, 4).Formula = Sum(Sheets(Me.lbxAccount.Value).Range("E4:E75"))