Results 1 to 2 of 2

Thread: Editing Formulas

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Editing Formulas

    Hi all

    Here is a tricky question;

    I'm doing some mortgage calculations using Excel's PMT formula, currently what I've been doing is this;

    I have an input sheet with my raw data - I then process the raw data in another sheet, where I'm doing numerous calculations. One of those is the PMT. So far I've been using a fixed loan period, based on estimates, but I would like to use the real periods instead - Is it possible to insert a reference based on a for next in a formula, like the PMT?

    /Nick

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Re: Editing Formulas

    So...'

    I managed to go around the problem of inserting variables into the PMT formula, but instead I've - of course - encountered another problem.

    Here is what I'm doing:
    VB Code:
    1. Sub flexvalue()
    2. Dim j As Double
    3. Dim k As Double
    4. Dim iSheet As Worksheet
    5. Dim nsheet As Worksheet
    6.  
    7.     Set iSheet = ActiveWorkbook.Sheets("Input")
    8.     Set nsheet = ActiveWorkbook.Sheets("Nedskrivning-7")
    9.    
    10.     For j = 1 To 10
    11.         For k = 1 To 25
    12.             If nsheet.Cells(k, "A").Value = iSheet.Cells(j, "O").Value Then
    13.                 nsheet.Range(Cells(k + 1, "A"), Cells(k + 1, "O").End(xlDown)).Select
    14.                 nsheet.Range("P17").Value = iSheet.Cells(j, "O").Value
    15.                 nsheet.Range("P18").Value = nsheet.Range("P17").Value - 1
    16.                 nsheet.Range("P19").Value = nsheet.Range("P18").Value - 1
    17.                 nsheet.Range("P20").Value = nsheet.Range("P19").Value - 1
    18.                 nsheet.Range("P21").Value = nsheet.Range("P20").Value - 1
    19.             End If
    20.         Next k
    21.     Next j
    22.        
    23.     Set iSheet = Nothing
    24.     Set nsheet = Nothing
    25.    
    26. End Sub

    However I can't use this part;
    VB Code:
    1. nsheet.Range("P17").Value = iSheet.Cells(j, "O").Value
    2.                 nsheet.Range("P18").Value = nsheet.Range("P17").Value - 1
    3.                 nsheet.Range("P19").Value = nsheet.Range("P18").Value - 1
    4.                 nsheet.Range("P20").Value = nsheet.Range("P19").Value - 1
    5.                 nsheet.Range("P21").Value = nsheet.Range("P20").Value - 1
    First off, becuase there must be an easier way - and more importantly, I will need to "control" somehow, so if the number is larger than 10, it should state 10 for the largest AND the number can't be lower than 1.

    So if the number is 35, it will write 10 instead, the next number will then be 9...8...7...until it reaches 1...after that nothing!

    Anyone out there who has a good idea?

    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width