+ Reply to Thread
Results 1 to 11 of 11

Auto Fill Formula to Variable Range.

  1. #1
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Auto Fill Formula to Variable Range.

    Hi.
    I have column dates in A and row headers in 1.

    The columns and rows change in size everyday.

    I'm trying to auto-fill a formula in B2 to the variable size of my range below Row 1 headers and to the right of Column A dates.

    So far, I have this, but I'm hitting errors. Does anyone one know I'm doing wrong?

    Please Login or Register  to view this content.
    I keep getting the Compiler error, "Argument not optional"

    Does any one know how to fix this?

    I can attach an example if necessary.

    Any help is greatly appreciated.

    Thanks

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Auto Fill Formula to Variable Range.

    You can't use Range.Select, you need to define the range you are using with a reference, e.g. Range("A1"). You could use
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Generally, using select in code doesn't serve much of a purpose and just slows things down. I haven't fully tested this (I haven't checked the formula works but I would expect you could use something like:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Re: Auto Fill Formula to Variable Range.

    Hey Yudlugar.

    Thanks for your response. The code you supplied works to a point, however, I'm receiving run-time error '1004': app defined or object defined error, on the line:
    Please Login or Register  to view this content.
    The code does copy the formula down, but not to the right. I'm trying to select that range and fill to the right the same way it was filled down, however, I'm having trouble capturing the range I want without using .select.

    Any ideas on the error?

    Thanks

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Auto Fill Formula to Variable Range.

    change ("1")
    Into
    1
    Or remove the quote mark from 1

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Auto Fill Formula to Variable Range.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Re: Auto Fill Formula to Variable Range.

    Hey AB33.
    I tried removing the quotations from 1, and I changed xlToLeft but I'm still getting Run-time error '1004.'

    This is confusing b/c the .FillDown part of the function is working fine, so I have no idea why it won't fill right.

    Thanks for the help.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Auto Fill Formula to Variable Range.

    The directions you can use for end are:
    xlup
    xldown
    xltoleft
    xltoright

    So you can't use xlright as the arguement for end...

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Auto Fill Formula to Variable Range.

    Please Login or Register  to view this content.
    is working because you are resizing rows with column1, but the right is resizing columns(rows) with column 1
    Try

    Please Login or Register  to view this content.
    OR

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Re: Auto Fill Formula to Variable Range.

    Hey Guys.
    I tried these different codes. The first one still results in Run-time error 1004 and the second line doesn't fill the selected code to the right.

    I tried splitting up my filldown and fillright into two different 'with' statements, selecting the data in "B" before filling right, but this didn't work either.
    Is there an easier way to FillRight only to the extent of the column headers?

    Please Login or Register  to view this content.
    Thanks for all your help so far.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Auto Fill Formula to Variable Range.

    We have been wrong all these time. The correct syntax should be

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Re: Auto Fill Formula to Variable Range.

    A member on MrExcel helped me find the correct line of code for this.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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