One more question - about msgbox..
OK, got my code from my previous post working, here it is:
VB Code:
Private Sub CmdSum_Click()
Set Comm = Worksheets(2).Range("J12:J50")
showComm = Application.WorksheetFunction.Sum(Comm)
Set Mort = Worksheets(2).Range("L12:L50")
showMort = Application.WorksheetFunction.Sum(Mort)
Set Life = Worksheets(2).Range("M12:M50")
showLife = Application.WorksheetFunction.Sum(Life)
Set Home = Worksheets(2).Range("N12:N50")
showHome = Application.WorksheetFunction.Sum(Home)
Set Profit = Worksheets(2).Range("J12:N50")
showProfit = Application.WorksheetFunction.Sum(Profit)
End Sub
I now want to use a Msgbox to make it look like this:
"Total Commission = (Comm)
Total Mortgage Fee = (Mort)
Total Life Fee = (Life)
Total Home Insurance = (Home)
Total Profit for the company = (Profit)"
Where the words in brackets are the variables from the above code, and formatted like above (a new line for each piece of info). Not done a lot with Msgboxes, so can anyone help?
Re: One more question - about msgbox..
This isn't complete, but it will give you the idea.
MsgBox "Total Commission = " & showComm & vbcrlf & _
"Total Mortgage Fee = " & showMort & vbcrlf & _
"Total Life Fee = " & showLife
the key is the vbCrLf which will put a new line in the msgbox.
Tg