Question: vba code has bugs and errors. pleae leave comments withhow it was fixed and a copyable code Sub TotalSales1() Dim lastDate As Date, total As

vba code has bugs and errors. pleae leave comments withhow it was fixed and a copyable code

Sub TotalSales1() Dim lastDate As Date, total As Currency, i As Long, ws As Worksheet MsgBox "You'll now be asked for a date. Then the total of all " & _ " sales up to that date will be totaled.", vbInformation, "Purpose" lastDate = InputBox("Enter the last date for the total.", "Last date") total = 0 For Each ws In ActiveWorkbook With Worksheets("ws").Range("A3") Do Until .Offset(i, 0) = "" If .Offset(i, 0) <= lastDate Then total = total + .Offset(i, 2) Loop End With Next MsgBox "The total of all sales through " & Format(lastDate, "1/1/99") & " is " & _ Format(total, "$#,##0"), vbInformation, "Sales Total" End Sub

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!