+ Reply to Thread
Results 1 to 2 of 2

Thread: A loop within a loop

  1. #1
    Registered User
    Join Date
    12-29-2009
    Location
    brooklyn, ny
    MS-Off Ver
    Excel 2003
    Posts
    13

    A loop within a loop

    Hi,

    I have a custom formula in the excel named "=rch(ticker, NUMBER)"
    "ticker" is a assigned name of the specific cell and NUMBER is just any number ex. 5432

    With a press of a button on the spreadsheet, I need to populate cells D17:G17 with such formula, but with different consecutive NUMBER following the next cell in that range.

    I am thinking about using a loop such that "Cells(17, cel)" and within each cell to loop "ans1 = rch & intr & rch2"
    In other words, in the cell D17, I need to show "=rch(ticker,2292)"
    in E17 to show "=rch(ticker,2293)"
    F19 "=rch(ticker,2295)"
    G19 "=rch(ticker,2296)"

    I came up with such code, However, since I am a noob in VBA, I am running into troubles .

    Sub calc2()
    
    Dim rch As String
    Dim rch2 As String
    Dim intr As Integer
    Dim cel As Integer
    Dim ans1 As String
    
    
    rch = "=rch(ticker,"
    rch2 = ")"
    
    intr = 0
    cel = 0
    
    
        For cel = 3 To 7
            Cells(17, cel).Value = ans1
            
            For intr = 2292 To 2296
            ans1 = rch & intr & rch2
            Next intr
     Next cel
           
     End Sub
    Can you please let me assist me.
    Thank you very much

  2. #2
    Registered User
    Join Date
    12-29-2009
    Location
    brooklyn, ny
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: A loop within a loop

    Maybe I need to do it with an array?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0