VBA: cannot figure out code

G

Guest

I am a novice to VBA and what I am trying to do I think is pretty simple but
I just don't know the code. On an excel spreadsheet I have a box where a
user can enter data. The data includes two interest rates and 2 dates for
each interest rate. One for when the interest rate will become effective and
the other for when it will no longer be effective. I want to make a macro
that will take the interest rate and dumpt it next to everypayment date that
it will be effective for. Right now the excel sheet is a long list of
payment dates with info like principal, interest, interest rate, etc.. The
code that I wrote is using if statements to determine whether the payment
date is between the two "effective dates". Anyway, here is the code I have
come up with thus far. Much could be wrong and I may have over complicated
things. Like I said I am a novice so there may be a much better way of doing
this.

Sub InputNewRates()
Dim Baseint As String
Dim FirstMOBase As Date
Dim SecondMOBase As Date
Dim FirstMOSwap As Date
Dim SecondMOSwap As Date
Dim SwapInt As String
Dim Range As Range
Dim rwindex As Integer
Baseint = [N2].Value
FirstMOBase = [n3].Value
SecondMOBase = [n4].Value
SwapInt = [n5].Value
FirstMOSwap = [n6].Value
SecondMOSwap = [n7].Value
For rwindex = 12 To 84
Set Range = Range(rwindex, 2)
For Each cel In Range
If cel < FirstMOBase Then
If cel > SecondMOBase Then
Set Range = Range(rwindex, 21)
Set cel = Baseint
End If
End If
Next
Next
End Sub
 
D

Don Guillett

Without seeing your wb etc can't tell but I think I might use FIND to find
the dates

r1=columns(2).find(1stdate).row
r2=columns(2).find(2nddate).row
range(cells(r1,3),cells(r2,3))=1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top