Results 1 to 3 of 3

How to have a dynamic Range in VBA in Excel?

Threaded View

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    97

    How to have a dynamic Range in VBA in Excel?

    Hi everyone!

    I have the code below to run for Paste Special (xlPasteFormulas, xlPasteValues)

    Sub CopyAsValues()
    
    'Pressing Ctrl + Shift + Z to run macro Paste Special
    '1 Copy Paste Formula from A5 to Range AC6:AC118880
    '2 Copy Paste Values from Range AC5:AC11800 to AB5:AB118880
    '3 Copy Paste Values AC6:AC118880  ( only Cell AC5 retains the formula )
    
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AC5").Copy
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AC6:AC11880").PasteSpecial _
            xlPasteFormulas
    
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AC5").Copy
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AB5:AB11880").PasteSpecial _
            xlPasteValues
    
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AC5").Copy
    Application.Workbooks("New Master TP 2018 - Copy.xlsm").Worksheets("TestPack Master").Range("AC6:AC11880").PasteSpecial _
            xlPasteValues
            
            Application.CutCopyMode = False
            
    End Sub

    ------My concern is how to make the . Range("AC6:AC11880") & .Range("AB5:AB11880") dynamic,
    so that when I am going to add "4 or more Data" the Range should also be increasing to something like . Range("AC6:AC11884") & .Range("AB5:AB11884)

    Any help is really appreciated.

    Thanks in advance,

    Rev12
    Last edited by Rev12; 06-16-2018 at 10:16 AM. Reason: wrap codes

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Match ComboBox with dynamic range, then add Textbox1 to dynamic range
    By Lasse Moe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2014, 01:26 AM
  2. Excel reset my dynamic name range
    By Sashen in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-19-2013, 02:11 PM
  3. Dynamic Range Column Chart w/ Dynamic Avg Line (Excel 2007)
    By BrokenBiker in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 10-04-2012, 11:40 AM
  4. Excel Dynamic Range
    By s1joshi in forum Excel General
    Replies: 5
    Last Post: 01-31-2010, 03:29 PM
  5. Dynamic Range Excel 2003
    By mattydalton in forum Excel General
    Replies: 4
    Last Post: 11-05-2009, 07:37 AM
  6. Dynamic Range in Excel
    By TCameron in forum Excel General
    Replies: 4
    Last Post: 07-28-2008, 05:13 PM
  7. [SOLVED] dynamic range for excel chart
    By bobf in forum Excel General
    Replies: 1
    Last Post: 01-26-2005, 08:06 AM

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