+ Reply to Thread
Results 1 to 3 of 3

Section Autofill count based on a value of a cell column

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    54

    Section Autofill count based on a value of a cell column

    Hello, I need help with creating an autofill section based on the the value of a cell G9.

    I have a layout from A12:I13 that I would like to copy down the row based on the value of G9.

    For Example G9 = 10

    A12 = 1
    A13 = 2

    Based on G9 = 10 I need to create the additional row to 10.

    Range selected "A12:I13" will copy an addional (G9=10 - 2 since 1 and 2 are already there)

    this will lead to A12:I13 + 8 = A12:I21.


    The code below does what I need it to do but I have to manually edit the I13 to I21 = 8 additional copy lines

       
            Range("A12:I13").Select
            Selection.AutoFill Destination:=Range("A12:I21"), Type:=xlFillDefault
    Last edited by khhoa; 03-03-2015 at 01:26 PM. Reason: Edit code

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Section Autofill count based on a value of a cell column

    Try this...

    Range("A12:I13").AutoFill Destination:=Range("A12:I12").Resize(Range("G9").Value), Type:=xlFillDefault
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-07-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    54

    Re: Section Autofill count based on a value of a cell column

    Quote Originally Posted by AlphaFrog View Post
    Try this...

    Range("A12:I13").AutoFill Destination:=Range("A12:I12").Resize(Range("G9").Value), Type:=xlFillDefault
    I am getting a Run-Time error '1004'

    This operation requires the merged cells to be identically sized.

    Is it because I have some cells in A12:I13 that are merged together, That is why it is selected and copy down.


    I just realized that this causes error because cells need to be even numbers since selected range is in two.
    Last edited by khhoa; 03-03-2015 at 02:41 PM. Reason: Code does not function correctly / improperly stated

+ 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. Autofill base on Active Cell and Autofill by row count of another sheet
    By enyak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2014, 10:06 PM
  2. How to autofill cells based on count of another column
    By rebeccanstewart in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2013, 06:26 PM
  3. VBA code ,Autofill color of a column based on cell value
    By mubashar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 11:50 AM
  4. Autofill based on Cell count?
    By treyUF in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2012, 02:27 AM
  5. Copy range and autofill ranges dependent on cell count in column A
    By thylander in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2011, 09:26 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