Results 1 to 10 of 10

Dynamic Range in Formulas VBA

Threaded View

  1. #1
    Registered User
    Join Date
    06-14-2021
    Location
    America
    MS-Off Ver
    Microsoft Excel for Office 365 MSO
    Posts
    32

    Dynamic Range in Formulas VBA

    Hi,

    How can I make the range in a formula to work with a dynamic range?

    * 'R2C5:R640C5' & 'R2C5:R45C5' (shown below) is a variable range on the spreadsheet and not a fixed one.
    * Attached example only has what's applicable to the questions.

    1. COUNTIF: Used to count the number of repetitions on each cell value (Item#). That'll be Column A in the attached example.

    ActiveCell.FormulaR1C1 = "=COUNTIF(R2C5:R640C5,RC[-6])"
    Range("K2").Select
    Selection.AutoFill Destination:=Range("K2:K" & Range("C" & Rows.Count).End(xlUp).Row)
    Range(Selection, Selection.End(xlDown)).Select

    2. INDEX & MATCH: Used to lookup and match 'Item#' and return 'HA#'. That'll be lookup Column A and match with Column B in Sheet#2, then return Column A from Sheet#2 to Column C.

    Range("L2").Select
    ActiveCell.FormulaR1C1 = _
    "=INDEX('HA Data'!R2C4:R45C4,MATCH('Sample Data'!RC[-7],'HA Data'!R2C5:R45C5,0),1)"
    Range("L2").Select
    Selection.AutoFill Destination:=Range("L2:L" & Range("C" & Rows.Count).End(xlUp).Row)
    Range(Selection, Selection.End(xlDown)).Select

    Hopefully this makes sense.
    Attached Files Attached Files
    Last edited by Maxpsb47; 10-13-2022 at 09:34 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Dynamic chart from a range containing formulas
    By chrismeeky in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-01-2018, 05:39 PM
  2. Dynamic range names and Formulas
    By rschoenb in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 11-21-2014, 11:49 AM
  3. Insert cells, fill formulas down, set formulas for dynamic range
    By Snickers65 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 01:43 PM
  4. [SOLVED] Dynamic range - ignoring formulas
    By HuskerBronco in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-23-2013, 01:31 PM
  5. [SOLVED] Formulas' on Dynamic Range
    By knocks420 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-09-2012, 02:34 PM
  6. dynamic range of formulas
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2006, 03:53 PM
  7. [SOLVED] dynamic range defined in VBA for use in formulas
    By yo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2005, 02:06 PM

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