Display results in a userform label

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
Can someone assist with a VBA code to display the results in a label for the selected row. The data location is as displayed, however the cursor will in column A. The formulas used are below...

Total Cost: =SUM(U8*T8,X8*W8,Z8*AA8,AC8*AD8,AF8*AG8)
Total Fees: =SUM(V8,Y8,AB8,AE8,AH8)

Thank you kindly for your assistance..

1676860523998.png

1676860549328.png
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
below code is helping you to calculate the accumulation even you have over 5 Lots, please see below,

Dim A, B as Long

' Assigned the start point at Range T8.
Range("T8").select
A = 0 ' as the Total Cost Value and set to Zero first
B = 0 ' as the Total Fees Value and set to Zero first

Do while Len(Activecell.value) <> 0
if Len(Activecell.value) <> 0 then
A = A + Activecell.value * Activecell.offset(0,1).value
B = B + Activecell.offset(0,2).value
Activecell.Offset(0,3).select
END IF
msgbox "Total Cost : $ " & Format(A, "0.00") & Chr(13) & _
"Total Fees : $ " & Format(B, "0.00")
Range("A" & Activecell.row).select
Loop
 
Upvote 0
Hi Justuptou..

1. I tested the code but it doesn't calculate correctly if I add addition data. (See data in green and msgbox in Image)
2. Is it possible to obtain the calculation without the cursor moving? The cursor will remain fixed in column A and I would like to select the row to obtain the data?
3. You mention of having additional lots, however no additional Lots will be added.

1676865659353.png
 
Upvote 0
Hi Justuptou..

1. I tested the code but it doesn't calculate correctly if I add addition data. (See data in green and msgbox in Image)
2. Is it possible to obtain the calculation without the cursor moving? The cursor will remain fixed in column A and I would like to select the row to obtain the data?
3. You mention of having additional lots, however no additional Lots will be added.

View attachment 85769
1676869546718.png

Sorry, Please change the coding in blue.
Sub Display_Msg()

Dim A, B

' Assigned the start point at Range T8.
Range("A2").Select
A = 0 ' as the Total Cost Value and set to Zero first
B = 0 ' as the Total Fees Value and set to Zero first

Do While Len(ActiveCell.Value) <> 0
If Len(ActiveCell.Value) <> 0 Then
A = A + ActiveCell.Value * ActiveCell.Offset(0, 1).Value
B = B + ActiveCell.Offset(0, 2).Value
ActiveCell.Offset(0, 3).Select
End If
Loop

Range("A" & ActiveCell.Row).Select
MsgBox "Total Cost : $ " & Format(A, "0.00") & Chr(13) & _
"Total Fees : $ " & Format(B, "0.00")


End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top