Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I want the following solution in Excel VBA The file Stock Prices.xlsx contains m

ID: 3677918 • Letter: I

Question

I want the following solution in Excel VBA

The file Stock Prices.xlsx contains monthly adjusted closing prices, adjusted
for dividends and stock splits, for WalTech’s stock from 2003 to early 2011.
(WalTech is a fictitious company.)
a. Write a sub called RecordHigh1 that takes a single argument called search-
Price. This sub searches down the list of prices for the first price that exceeds
the searchPrice argument. If it finds one, it displays the corresponding date
in a message, something similar to, “The first date WalTech stock price
exceeded _ was _.” If the price never exceeded the argument searchPrice, it
displays a message to this effect. Next, write a Records sub that uses an input
box to ask the user for a price and then calls RecordHigh1 with this price as
the argument.

1 Adjusted closing prices 2 Date 3 Jan-03 4 Feb-03 5 Mar-03 6 Apr-03 7 May-03 8 Jun-03 9 Jul-03 10 Aug-03 11 Sep-03 12 Oct-03 13 Nov-03 14 Dec-03 15 Jan-04 16 Feb-04 17 Mar-04 18 Apr-04 19 May-04 20 Jun-04 21 Jul-04 22 Aug-04 23 Sep-04 24 Oct-04 25 Nov-04 Price 12.940 12.794 12.848 12.444 12.725 12.962 13.460 13.521 14.221 14.540 15.423 15.422 15.360 15.387 15.132 12.890 13.566 12.778 12.267 12.432 11.785 12.534 13.553 Data

Explanation / Answer

Sub RecordHigh1(ByVal searchPrice As Double)


Dim D As Date


For i = 1 To Range("B1").End(xlDown).Row

If Range("B" & i) > searchPrice Then
' This way i search a date range rather than a specific date
D = Range("A" & i).Value
MsgBox ("The first date WalTech stock price exceeded " & Range("B" & i) & " was " & D)
End
End If

Next
MsgBox ("Stock price does not exceed the given")
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote