+ Reply to Thread
Results 1 to 4 of 4

How to reference equations with for loop index notation in macros?

  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    los angeles
    MS-Off Ver
    Excel 2010
    Posts
    12

    How to reference equations with for loop index notation in macros?

    Hi,

    I am having a problem with a code in excel; I have searched the solution for 2 days on the internet and it seems there is no solution to something so simple. I want the code to write the function "= .15 * prices!Bi" where the index i is any integer from 1 to 1175 corresponding with the if statement. B is the column and i is the variable number


    Here is the code I have in excel:

    Sub test()
    Dim i As Integer
    Dim j As Integer

    For i = 1 To 1175
    For j = 1 To 439

    If (Worksheets("prices").Cells(i, 1).Value = Worksheets("beachwood").Cells(j, 1).Value) Then
    Worksheets("beachwood").Cells(j, 2).Formula = "= .15 * prices!Bi"
    End If
    Next j
    Next i

    End Sub

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: How to reference equations with for loop index notation in macros?

    Try this

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    12-30-2012
    Location
    los angeles
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: How to reference equations with for loop index notation in macros?

    Thank you so much that solves my problem, but before you mark this as solved, please tell me how to solve this:

    "= .15 * prices!Bi + prices!Bi"

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: How to reference equations with for loop index notation in macros?

    This should do it

    Please Login or Register  to view this content.
    Also should use code tags when posting codes. You can click on the # sign above and paste your code between the code tags [Code]Paste Here[Code]

    Also if your satisfied with the solution then you can mark the thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1