+ Reply to Thread
Results 1 to 4 of 4

Filling formula for a wide range of cells.

  1. #1
    Registered User
    Join Date
    03-16-2015
    Location
    Bangkok
    MS-Off Ver
    2007
    Posts
    28

    Filling formula for a wide range of cells.

    Hi,

    I need to put in functions/formula in a range of cells from C4:AEM121
    With my reference cell being A4:A121 and another reference cell being C2:AEM2

    for the first cell C4 the formula would be
    =TR(C2,"TR.CompanyMarketCap","SDate=#1",,A4)

    for the second cell C5 the formula would be
    =TR(C2,"TR.CompanyMarketCap","SDate=#1",,A5)

    for the first cell D4 the formula would be
    =TR(D2,"TR.CompanyMarketCap","SDate=#1",,A4)

    and so on. Please see attached file

    I could fix the reference cell C2 by using $C$2, but I would have to do this for all the columns until the last column AME which is quite tedious.
    Thus I'd like to know if there are any way to fill in the functions more easily and less time consuming, or perhaps a VBA macro could be used?


    Thank you for suggestions and help.

    Vku
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Filling formula for a wide range of cells.

    This is so easy.

    Put all your formulas into one row of your spreadsheet.

    Start the macro recorder and select each cell and the one below it in turn in turn, click on the formula and press enter.
    stop the macro editor.

    you will have something like:-

    Please Login or Register  to view this content.
    ou can edit that down to:-

    Please Login or Register  to view this content.

    Once you have edited all your code you need two more things.

    First to count the number of rows.

    Please Login or Register  to view this content.
    finds the last used row in column 1

    Please Login or Register  to view this content.
    finds the last used row in column 2

    Finally use find / replace to replace

    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Replacing all occurrences.
    Last edited by mehmetcik; 05-01-2015 at 01:29 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-16-2015
    Location
    Bangkok
    MS-Off Ver
    2007
    Posts
    28

    Re: Filling formula for a wide range of cells.

    Thank you mehmetcik,

    the code

    Sub Macro1()
    Range("C4").FormulaR1C1 = "=TR(R2C3,""TR.CompanyMarketCap"",""SDate=#1"",,RC[-2])"
    End Sub

    works well for the cell C4, but i'm not quite sure how to implement it to cover the whole range of cells.

    could you please elaborate, i'm quite new to VBA

    Many thanks!

    Vku

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Filling formula for a wide range of cells.

    I get errors here.

    so I cannot do it for you.

    Please Login or Register  to view this content.
    Will put that formula in 4 cells C4, C5, D4, D5


    I have created this Macro to help you.


    If you copy your recorded macro into column A of an excel spreadsheet and run this macro,

    It will tidy up your macro for you.

    Once its done its job, copy the macro back to visual basic.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 05-01-2015 at 05:08 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create a formula to enable currency choice across wide range of cells
    By garethmore1 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-31-2013, 04:18 PM
  2. Filling a formula on a large range of cells
    By Carnifex930 in forum Excel General
    Replies: 3
    Last Post: 06-20-2010, 04:28 PM
  3. Applying If statement to wide range of cells
    By MountainGoat in forum Excel General
    Replies: 3
    Last Post: 08-21-2008, 10:56 AM
  4. Formula for number's /Wide range
    By Newbietoexcel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-11-2008, 06:06 PM
  5. Filling a range of cells defined by input into a text box
    By Zeke XA3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2006, 07:37 AM

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