+ Reply to Thread
Results 1 to 7 of 7

Macro to copy varying number of cells

Hybrid View

socalobie Macro to copy varying number... 06-19-2014, 12:15 AM
humdingaling Re: Macro to copy varying... 06-19-2014, 12:32 AM
socalobie Re: Macro to copy varying... 06-19-2014, 12:44 AM
humdingaling Re: Macro to copy varying... 06-19-2014, 12:36 AM
rcm Re: Macro to copy varying... 06-19-2014, 12:36 AM
socalobie Re: Macro to copy varying... 06-19-2014, 01:07 AM
humdingaling Re: Macro to copy varying... 06-20-2014, 03:58 AM
  1. #1
    Registered User
    Join Date
    05-25-2014
    Posts
    6

    Macro to copy varying number of cells

    I want a macro to copy a portion of a column of numbers. The number of cells copied changes each month.

    In the attached sample cell D1 has the number of cells to be copied. The cells I want to copy are in column B. in the sample I want to copy the first 15 cells in column B i.e. 1 through 17.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to copy varying number of cells

    copy to where?
    also i think your confusing columns with rows
    also does column A do anything here?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    05-25-2014
    Posts
    6

    Re: Macro to copy varying number of cells

    Sorry about the confusion. I knew how to make the macro paste so I did not include pasting in my request. The numbers in column A is just a counter.

    I just ran the macro you suggested and it worked great. It is what I needed.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to copy varying number of cells

    Sub CopyRange()
        
        ' deletes whatever is in column F....remove this code if not required
        Range("F:F").Delete
        
        'Just selected F1 for this example but you can change to whatever you want
        Range("B1:B" & Range("D1").Value).Copy Range("F1")
        
    End Sub

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Macro to copy varying number of cells

    just change the number of cells you want to copy. the output would be reflected in column F.

    To look at the code click on the programmer option and then click on view code.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-25-2014
    Posts
    6

    Re: Macro to copy varying number of cells

    Thank for the reply. Your method requires the macro to be changed each month. humdingaling's macro gives me the result without changing the macro each month.

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to copy varying number of cells

    Cheers
    Thanks for the rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Match, Copy and Paste Column Headers - varying number of columns
    By itcher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2013, 10:49 AM
  2. SUM on varying number of cells in VBA
    By mathmani in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-19-2013, 09:46 AM
  3. Sum total for varying number of cells
    By peri1224 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-30-2009, 12:34 PM
  4. Can I use CONCATENATE with a varying number of cells?
    By djbosworth in forum Excel General
    Replies: 1
    Last Post: 09-22-2009, 07:57 AM
  5. Averaging A Varying Total Across A Number Of Cells
    By xStephaniex in forum Excel General
    Replies: 1
    Last Post: 06-08-2008, 10:47 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