+ Reply to Thread
Results 1 to 4 of 4

Copy formulas downward within a range using VBA

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Copy formulas downward within a range using VBA

    I found a piece of code here: http://www.ozgrid.com/forum/showthre...py+formula+vba that i modified to use for my own workbook.

    The code below works great. I tried adding a few notes to try to help me understand it.

    Please Login or Register  to view this content.

    What i am trying to find out is, can the above code be modified to work within a range of rows instead of looking at an entire column? For example, i want it to only work on rows 25:50 (row 25 contains the formulas i want to copy downward) instead of the entire sheet. Then i could copy the formula, call it a new name, fix the row numbers, and run it again on rows 55:72, and continue on for about 8 different ranges.
    Last edited by PY_; 12-15-2010 at 01:50 AM.

  2. #2
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Copy formulas downward within a range using VBA

    Actually after sleeping on it, i believe its as simple as changing the line:

    lastrow = .Cells(Rows.Count, "A").End(xlUp).Row

    to instead read "lastrow = 50" (or whatever number i need it to stop at)
    Last edited by PY_; 12-15-2010 at 09:54 AM.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Copy formulas downward within a range using VBA

    You shouldn't need code to copy formulas down, which version of Excel are you using?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Copy formulas downward within a range using VBA

    2007

    I am trying to save file size by only copying the formula to rows that meet a specific criteria based on cell values. The code above works fine when looking at a full column but im still having trouble looking at a range insted. It is locating and filtering the correct rows but it errors our at the line: rngVisible.PasteSpecial (xlPasteFormulas) 'Paste Formulas

    I think it has something to do with the offset but not 100% sure so I am still working on a solution to it.
    Last edited by PY_; 12-15-2010 at 11:38 AM.

+ 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