mykulpasskwa
Board Regular
- Joined
- Mar 20, 2018
- Messages
- 66
I'm using a Multipage (13 pages) on a UserForm and on each page I have 8 text boxes. These text boxes get calculated and the resulting value is entered into a cell on the worksheet. I have one set of controls (Enter, Calculate, and Clear) on the UserForm section. The 13 pages represent semesters/terms and the 8 text boxes represent the fees for each semester. I'm trying to figure out the best way to enter different values on each page. I'm pretty new to VBA and this is the first time I'm using Multipage. I have two terms below as an example, but I was planning on doing the same thing for 13 more terms. In the future it may be more than 13--Im trying to add an option where you can insert or delete terms (rows) as needed. I know that it is very bloated, but I don't know how to make it more efficient. Any advice?
Code:
Private Sub FeesTotalBtn_Click()
'Enter button that adds together all of the fees entered into the FeesForm
Dim resp
Dim ws As Worksheet
Dim TandFBalance As Currency
Dim TandFBalance2 As Currency
Set ws = Worksheets("Ch. 33 YR")
'Term 1
Range("D4") = Val(UgGradFeeTxtBox.Text) + Val(StuActFeeTxtBox.Text) + Val(StuCentFeeTxtBox.Text) + Val(StuRecFeeTxtBox.Text) + Val(HlthPlnFeeTxtBox.Text) + Val(UHCSFeeTxtBox.Text) + Val(Misc1FeeTxtBox.Text) + Val(Misc2FeeTxtBox.Text) 'Adds the fees together
ws.Range("A139") = UgGradFeeTxtBox.Value 'Saves Undergraduate or Graduate fee ''Check control source for data location
ws.Range("B139") = StuActFeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("C139") = StuCentFeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("D139") = StuRecFeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("E139") = HlthPlnFeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("F139") = UHCSFeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("G139") = Misc1FeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
ws.Range("H139") = Misc2FeeTxtBox.Value 'Saves Student Activity fee ''Check control source for data location
'Term 2
Range("D5") = Val(UgGradFeeTxtBox2.Text) + Val(StuActFeeTxtBox2.Text) + Val(StuCentFeeTxtBox2.Text) + Val(StuRecFeeTxtBox2.Text) + Val(HlthPlnFeeTxtBox2.Text) + Val(UHCSFeeTxtBox2.Text) + Val(Misc1FeeTxtBox2.Text) + Val(Misc2FeeTxtBox2.Text) 'Adds the fees together
ws.Range("A140") = UgGradFeeTxtBox2.Value
ws.Range("B140") = StuActFeeTxtBox2.Value
ws.Range("C140") = StuCentFeeTxtBox2.Value
ws.Range("D140") = StuRecFeeTxtBox2.Value
ws.Range("E140") = HlthPlnFeeTxtBox2.Value
ws.Range("F140") = UHCSFeeTxtBox2.Value
ws.Range("G140") = Misc1FeeTxtBox2.Value
ws.Range("H140") = Misc2FeeTxtBox2.Value
Unload FeesForm
'Term1
TandFBalance = Ch33YR.Range("C4") + Ch33YR.Range("D4") - Ch33YR.Range("E4") + (Ch33YR.Range("F4") * -1 - Ch33YR.Range("G4")) - Ch33YR.Range("H4") + Ch33YR.Range("I4")
Ch33YR.Range("J4") = TandFBalance
'Term2
TandFBalance2 = Ch33YR.Range("C5") + Ch33YR.Range("D5") - Ch33YR.Range("E5") + (Ch33YR.Range("F5") * -1 - Ch33YR.Range("G5")) - Ch33YR.Range("H5") + Ch33YR.Range("I5")
Ch33YR.Range("J5") = TandFBalance2
End Sub