+ Reply to Thread
Results 1 to 2 of 2

VBA code to insert formula with automatic cell referencing & size

Hybrid View

  1. #1
    Registered User
    Join Date
    03-06-2012
    Location
    Newport Beach, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    VBA code to insert formula with automatic cell referencing & size

    Hi,

    In the attached spreadsheet, I am trying to insert the following formula starting in cell C2 then to automatically fill to the last cell based on the number of IDs in column A.
    =IF(B2="Y",BDP(I3&" ISIN",$C$1, "PX_ASK",D2,"SETTLE_DT",TEXT(D2,"yyyymmdd")),BDP(I3&" ISIN",$C$1, "PX_ASK",E2,"SETTLE_DT",TEXT(E2,"yyyymmdd")))
    So I need the VBA code to:
    - automatically change for cell references
    - automatically fill to the last row of data so if I were to add another row ID, the macro would recognize that and fill accordingly.
    Book5.xlsx

    Thanks in advance,

    Kevin

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: VBA code to insert formula with automatic cell referencing & size

    Hi vbatech,

    Try using below macro:-

    Sub copyy()
    i = Range("a1048576").End(xlUp).Row
    Range("c2").Copy
    Range(Selection, "c" & i).PasteSpecial xlPasteFormulas
    End Sub

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

+ 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