Hi All,
I was trying to use the following VB Script to calculate the Sales figure for a particular commodity and of a particular region and the end result being displayed in a MSGBOX. Finally, I get the message box but with no values in it.
------------------------------------------------------------------------------------
Private Sub Sales()
Dim Example As Worksheet
Set Example = ThisWorkbook.Sheets("Example")
LastRow = Example.Cells(Rows.Count, 1).End(xlUp).Row
SelRow = Selection.Row
Category = Example.Cells(SelRow, 9)
City = Example.Cells(SelRow, 5)
For x = 2 To LastRow
If Example.Cells(x, 9) = Category And Example.Cells(x, 5) = City Then
Tsale = Tsale + Example.Cells(x, 11)
End If
Next x
Stop
MsgBox "The total sale for" & Category & " and " & City & " is " & Tsale, vbOKOnly, "Msg1"
End Sub
-----------------------------------------------------------------------------------------------
Please help me out folks..
Bookmarks