Results 1 to 17 of 17

Copy Range of Formulas to a Variable Range of Cells

Threaded View

  1. #1
    Registered User
    Join Date
    02-08-2014
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    10

    Copy Range of Formulas to a Variable Range of Cells

    Hi everyone,

    I have difficulties trying to writing some VBA codes. As what I have attached, I am trying to copy a range of formulas, and paste them into another range of cells.

    For example, when excel detects column A with "Apple", I want to copy formulas from M2:Z2 and copy them to M24:M34. The thing is that the range of M24:M34 is more of variable and always changing, it could be M14:M64 the next day. How should I amend the codes to paste the formulas from M2:Z2 to the M columns between "Apple" and "Pear". Sorry if this is confusing.. but please let me know if there is any uncertainty. Thanks

    Sub copyFormula()

    myrow = 21
    Lastrow = Range("A65000").End(xlUp).Row
    For i = 21 To Lastrow
    Range("A" & myrow).Select

    If ActiveCell.Value = "Apple" Then

    Range("M2:Z2").Select
    Selection.Copy
    Range("M24:M34").Select
    ActiveSheet.Paste

    End If
    myrow = myrow + 1
    Next I
    End sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy range of cells, AND their formulas?
    By horsefish01 in forum Excel General
    Replies: 2
    Last Post: 05-28-2015, 06:49 PM
  2. Copy only cells that contain values from a range cells that contain formulas to next row
    By gjwilson1216 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2015, 11:12 AM
  3. Copy range of cells using variable criteria and named ranges
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2014, 01:07 PM
  4. [SOLVED] Copy Variable to a Range of Cells
    By Metrazal in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-26-2014, 10:52 AM
  5. [SOLVED] Copy range from multiple sheets, into a master sheet and moving over by variable col range
    By g1eagle in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2012, 01:36 PM
  6. [SOLVED] Copy/Paste Values from Variable Range to Corresponding Variable Range
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2012, 08:20 AM
  7. Copy only Visible Cells of a Variable Range...
    By Damian Carrillo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2005, 10:05 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