+ Reply to Thread
Results 1 to 3 of 3

Using Autofill knowing row and column number

  1. #1
    Fred Smith
    Guest

    Using Autofill knowing row and column number

    I want to do the programmatic equivalent of dragging the fill handle down
    one row. I know the row and column number of the destination cell. I tried:

    ..cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)

    but I got a range error. What's the correct syntax? Also, what's the syntax
    if I want to fill a range of cells (eg, columns 12 to17)?

    --
    Thanks,
    Fred





  2. #2
    Tom Ogilvy
    Guest

    Re: Using Autofill knowing row and column number

    Sub AA()
    Dim NextRow As Long
    Dim rng As Range
    NextRow = 10
    With ActiveSheet
    Set rng = .Range(.Cells(NextRow - 1, 2), .Cells(NextRow, 2))
    .Cells(NextRow - 1, 2).AutoFill Destination:=rng
    End With
    End Sub

    --
    Regards,
    Tom Ogilvy




    "Fred Smith" <[email protected]> wrote in message
    news:%[email protected]...
    > I want to do the programmatic equivalent of dragging the fill handle down
    > one row. I know the row and column number of the destination cell. I

    tried:
    >
    > .cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)
    >
    > but I got a range error. What's the correct syntax? Also, what's the

    syntax
    > if I want to fill a range of cells (eg, columns 12 to17)?
    >
    > --
    > Thanks,
    > Fred
    >
    >
    >
    >




  3. #3
    Dave Peterson
    Guest

    Re: Using Autofill knowing row and column number

    How about:

    Option Explicit
    Sub testme01()
    Dim NextRow As Long
    NextRow = 3 'test data only
    With ActiveSheet
    .Cells(NextRow - 1, 2).AutoFill _
    Destination:=.Cells(NextRow - 1, 2).Resize(2, 1)
    End With
    End Sub



    Fred Smith wrote:
    >
    > I want to do the programmatic equivalent of dragging the fill handle down
    > one row. I know the row and column number of the destination cell. I tried:
    >
    > .cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)
    >
    > but I got a range error. What's the correct syntax? Also, what's the syntax
    > if I want to fill a range of cells (eg, columns 12 to17)?
    >
    > --
    > Thanks,
    > Fred


    --

    Dave Peterson

+ 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