ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

writing VBA code for an excel sheet, i keep getting run time error 1004 application or object defined error. my code reads as follows.

by | Nov 28, 2023 | engineering

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

writing VBA code for an excel sheet, i keep getting run time error 1004 application or object defined error.

my code reads as follows.

Option Explicit

Sub tours()

‘Define Input variables

Dim p As Integer

Dim h As Integer

Dim sbp As Integer

Dim lbp As Integer

Dim ehp As Double

p = Worksheets(“sheet1”).Range(“d6”).Value

h = Worksheets(“sheet1”).Range(“d8”).Value

sbp = Worksheets(“sheet1”).Range(“e30”).Value

lbp = Worksheets(“sheet1”).Range(“e31”).Value

ehp = Worksheets(“sheet1”).Range(“e33”).Value

‘ [There should be five total input variables.]

‘Define Output variables

Dim NSB As Integer

Dim NLB As Integer

Dim SE As Currency

Dim LE As Currency

Dim SEHC As Currency

Dim LEHC As Currency

Dim TSBP As Currency

Dim TLBP As Currency

Dim ECH As Integer

Dim tp As Currency

‘Check to see if over 5 hours long

If h > 5 Then ECH = (h – 5)

If h < 5 Then ECH = 0

‘Find correct number of each bus

If p > 90 Then NSB = 0 And NLB = 2

If p > 70 Then NSB = 1 And NLB = 1

If p > 55 Then NSB = 2 And NLB = 0

If p > 35 Then NSB = 0 And NLB = 1

If p < 35 Then NSB = 1 And NLB = 0

‘Find extension price for buses

SE = NSB * sbp

LE = NLB * lbp

‘ [Now that you know the number of buses, you can figure out the extended prices.]

‘ [This is simply the number of buses times the appropriate base rate.]

‘Calculate extra hourly charge, if any

If ECH > 0 Then SEHC = SE * ehp * ECH And LEHC = LE * ehp * ECH

If ECH >= 5 Then SEHC = (4 * ehp * SE) And LEHC = (4 * ehp * LE)

‘ [Here you can do some checks to see how many “extra” hours need to be charged.]

‘ [Remember that the number of extra hours that are charged for is capped at 4.]

‘Add up the totals

TSBP = SE + SEHC

TLBP = LE + LEHC

tp = TSBP + TLBP

‘ [Now you just add up the various charges for the total bus prices, which also combine into the total.]

‘Outputs

Worksheets(“sheet1”).Range(“d12”).Value = ECH

Worksheets(“sheet1”).Range(“c16”).Value = NSB

Worksheets(“sheet1”).Range(“c18”).Value = SE

Worksheets(“sheet1”).Range(“e16”).Value = NLB

Worksheets(“sheet1”).Range(“e18”).Value = LE

Worksheets(“sheet1”).Range(“c20”).Value = SEHC

Worksheets(“sheet1”).Range(“e20”).Value = LEHC

Worksheets(“sheet1”).Range(“c22”).Value = TSBP

Worksheets(“sheet1”).Range(“e22”).Value = TLBP

Worksheets(“sheet1”).Range(“d24”).Value = tp

‘ [Now spit out all 10 of the output variables to their appropriate places on the spreadsheet.]

End Sub

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!