Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default VBA: cannot figure out code

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default cannot figure out code

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not figure out the code for the chart layout type I want AccessQuestion Charts and Charting in Excel 0 March 19th 10 08:21 PM
HOW TO 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Excel Worksheet Functions 3 December 30th 08 03:04 PM
Unable to figure out VBA Code needed Kieranz[_2_] Excel Programming 3 March 5th 07 01:34 PM
Code to Save As, then Open - can't figure it out! [email protected] Excel Discussion (Misc queries) 0 May 25th 06 09:18 PM
Can anyone figure this code problem please simonsmith Excel Discussion (Misc queries) 1 May 18th 06 08:20 PM


All times are GMT +1. The time now is 09:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"