+ Reply to Thread
Results 1 to 6 of 6

AutoFill on selection

  1. #1
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256

    AutoFill on selection

    Hi all,

    Trying to use AutoFill on a selected range instead of a hardcoded range. Ie: if i have a formula in B1,
    then i select B1 and highlight a range. I want the formula copied as progressive into the range.
    Trying stuff like this with no joy.

    Sub FillTest()
    With Selection
    '.AutoFill Destination = fillRange
    '.AutoFill (Destination = fillRange)
    'SourceRange.AutoFill Destination:=fillRange
    End With
    End Sub

    Sub FillTest()
    Selection.AutoFill Destination:=ActiveCell.Range("Want Selected range here"), _
    Type:=xlFillDefault
    End Sub
    Thx
    Dave
    "The game is afoot Watson"

  2. #2
    Dave Peterson
    Guest

    Re: AutoFill on selection

    Does progressive mean that you want to fill the cells row by row (one by one)?

    Or you just want to fill that formula into a larger range--say based on the last
    cell used in column A?

    Option Explicit
    Sub testme()
    Dim LastRow As Long
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    .Range("B1").AutoFill Destination:=.Range("B1:b" & LastRow)
    End With
    End Sub


    Desert Piranha wrote:
    >
    > Hi all,
    >
    > Trying to use AutoFill on a selected range instead of a hardcoded
    > range. Ie: if i have a formula in B1,
    > then i select B1 and highlight a range. I want the formula copied as
    > progressive into the range.
    > Trying stuff like this with no joy.
    >
    > Sub FillTest()
    > With Selection
    > '.AutoFill Destination = fillRange
    > '.AutoFill (Destination = fillRange)
    > 'SourceRange.AutoFill Destination:=fillRange
    > End With
    > End Sub
    >
    > Sub FillTest()
    > Selection.AutoFill Destination:=ActiveCell.Range("Want Selected range
    > here"), _
    > Type:=xlFillDefault
    > End Sub
    >
    > --
    > Desert Piranha
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=519047


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Hi Dave,

    What you have here, does what i am doing, with the AutoFill,
    except instead of hard coding the range i want to select the range.
    like
    .ActiveCell.AutoFill Destination:=.Range(Selection)

    Thx
    Dave
    Quote Originally Posted by Dave Peterson
    Does progressive mean that you want to fill the cells row by row (one by one)?

    Or you just want to fill that formula into a larger range--say based on the last
    cell used in column A?

    Option Explicit
    Sub testme()
    Dim LastRow As Long
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    .Range("B1").AutoFill Destination:=.Range("B1:b" & LastRow)
    End With
    End Sub


    Desert Piranha wrote:
    >
    > Hi all,
    >
    > Trying to use AutoFill on a selected range instead of a hardcoded
    > range. Ie: if i have a formula in B1,
    > then i select B1 and highlight a range. I want the formula copied as
    > progressive into the range.
    > Trying stuff like this with no joy.
    >
    > Sub FillTest()
    > With Selection
    > '.AutoFill Destination = fillRange
    > '.AutoFill (Destination = fillRange)
    > 'SourceRange.AutoFill Destination:=fillRange
    > End With
    > End Sub
    >
    > Sub FillTest()
    > Selection.AutoFill Destination:=ActiveCell.Range("Want Selected range
    > here"), _
    > Type:=xlFillDefault
    > End Sub
    >
    > --
    > Desert Piranha
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=519047


    --

    Dave Peterson

  4. #4
    Dave Peterson
    Guest

    Re: AutoFill on selection

    So you have a selection of cells and you want to fill the top row down through
    the selected area?

    Option Explicit
    Sub testme2()
    Dim myRng As Range
    Set myRng = Selection.Areas(1)
    myRng.Rows(1).AutoFill Destination:=myRng
    End Sub




    Desert Piranha wrote:
    >
    > Hi Dave,
    >
    > What you have here, does what i am doing, with the AutoFill,
    > except instead of hard coding the range i want to select the range.
    > like
    > ActiveCell.AutoFill Destination:=.Range(Selection)
    >
    > Thx
    > Dave
    > Dave Peterson Wrote:
    > > Does progressive mean that you want to fill the cells row by row (one by
    > > one)?
    > >
    > > Or you just want to fill that formula into a larger range--say based on
    > > the last
    > > cell used in column A?
    > >
    > > Option Explicit
    > > Sub testme()
    > > Dim LastRow As Long
    > > With ActiveSheet
    > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > .Range("B1").AutoFill Destination:=.Range("B1:b" & LastRow)
    > > End With
    > > End Sub
    > >
    > >
    > > Desert Piranha wrote:
    > > >
    > > > Hi all,
    > > >
    > > > Trying to use AutoFill on a selected range instead of a hardcoded
    > > > range. Ie: if i have a formula in B1,
    > > > then i select B1 and highlight a range. I want the formula copied as
    > > > progressive into the range.
    > > > Trying stuff like this with no joy.
    > > >
    > > > Sub FillTest()
    > > > With Selection
    > > > '.AutoFill Destination = fillRange
    > > > '.AutoFill (Destination = fillRange)
    > > > 'SourceRange.AutoFill Destination:=fillRange
    > > > End With
    > > > End Sub
    > > >
    > > > Sub FillTest()
    > > > Selection.AutoFill Destination:=ActiveCell.Range("Want Selected

    > > range
    > > > here"), _
    > > > Type:=xlFillDefault
    > > > End Sub
    > > >
    > > > --
    > > > Desert Piranha
    > > >
    > > >

    > > ------------------------------------------------------------------------
    > > > Desert Piranha's Profile:

    > > http://www.excelforum.com/member.php...o&userid=28934
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=519047
    > >
    > > --
    > >
    > > Dave Peterson

    >
    > --
    > Desert Piranha
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=519047


    --

    Dave Peterson

  5. #5
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Hi Dave,

    Yep, Thats it. "Thank you Very Much Dave".

    Thx
    Dave
    Quote Originally Posted by Dave Peterson
    So you have a selection of cells and you want to fill the top row down through
    the selected area?

    Option Explicit
    Sub testme2()
    Dim myRng As Range
    Set myRng = Selection.Areas(1)
    myRng.Rows(1).AutoFill Destination:=myRng
    End Sub




    Desert Piranha wrote:
    >
    > Hi Dave,
    >
    > What you have here, does what i am doing, with the AutoFill,
    > except instead of hard coding the range i want to select the range.
    > like
    > ActiveCell.AutoFill Destination:=.Range(Selection)
    >
    > Thx
    > Dave
    > Dave Peterson Wrote:
    > > Does progressive mean that you want to fill the cells row by row (one by
    > > one)?
    > >
    > > Or you just want to fill that formula into a larger range--say based on
    > > the last
    > > cell used in column A?
    > >
    > > Option Explicit
    > > Sub testme()
    > > Dim LastRow As Long
    > > With ActiveSheet
    > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > .Range("B1").AutoFill Destination:=.Range("B1:b" & LastRow)
    > > End With
    > > End Sub
    > >
    > >
    > > Desert Piranha wrote:
    > > >
    > > > Hi all,
    > > >
    > > > Trying to use AutoFill on a selected range instead of a hardcoded
    > > > range. Ie: if i have a formula in B1,
    > > > then i select B1 and highlight a range. I want the formula copied as
    > > > progressive into the range.
    > > > Trying stuff like this with no joy.
    > > >
    > > > Sub FillTest()
    > > > With Selection
    > > > '.AutoFill Destination = fillRange
    > > > '.AutoFill (Destination = fillRange)
    > > > 'SourceRange.AutoFill Destination:=fillRange
    > > > End With
    > > > End Sub
    > > >
    > > > Sub FillTest()
    > > > Selection.AutoFill Destination:=ActiveCell.Range("Want Selected

    > > range
    > > > here"), _
    > > > Type:=xlFillDefault
    > > > End Sub
    > > >
    > > > --
    > > > Desert Piranha
    > > >
    > > >

    > > ------------------------------------------------------------------------
    > > > Desert Piranha's Profile:

    > > http://www.excelforum.com/member.php...o&userid=28934
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=519047
    > >
    > > --
    > >
    > > Dave Peterson

    >
    > --
    > Desert Piranha
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=519047


    --

    Dave Peterson

  6. #6
    Dave Peterson
    Guest

    Re: AutoFill on selection

    Glad it works ok.

    Desert Piranha wrote:
    >
    > Hi Dave,
    >
    > Yep, Thats it. "Thank you Very Much Dave".
    >
    > Thx
    > Dave
    > Dave Peterson Wrote:
    > > So you have a selection of cells and you want to fill the top row down
    > > through
    > > the selected area?
    > >
    > > Option Explicit
    > > Sub testme2()
    > > Dim myRng As Range
    > > Set myRng = Selection.Areas(1)
    > > myRng.Rows(1).AutoFill Destination:=myRng
    > > End Sub
    > >
    > >
    > >
    > >
    > > Desert Piranha wrote:
    > > >
    > > > Hi Dave,
    > > >
    > > > What you have here, does what i am doing, with the AutoFill,
    > > > except instead of hard coding the range i want to select the range.
    > > > like
    > > > ActiveCell.AutoFill Destination:=.Range(Selection)
    > > >
    > > > Thx
    > > > Dave
    > > > Dave Peterson Wrote:
    > > > > Does progressive mean that you want to fill the cells row by row

    > > (one by
    > > > > one)?
    > > > >
    > > > > Or you just want to fill that formula into a larger range--say

    > > based on
    > > > > the last
    > > > > cell used in column A?
    > > > >
    > > > > Option Explicit
    > > > > Sub testme()
    > > > > Dim LastRow As Long
    > > > > With ActiveSheet
    > > > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > > > .Range("B1").AutoFill Destination:=.Range("B1:b" & LastRow)
    > > > > End With
    > > > > End Sub
    > > > >
    > > > >
    > > > > Desert Piranha wrote:
    > > > > >
    > > > > > Hi all,
    > > > > >
    > > > > > Trying to use AutoFill on a selected range instead of a

    > > hardcoded
    > > > > > range. Ie: if i have a formula in B1,
    > > > > > then i select B1 and highlight a range. I want the formula copied

    > > as
    > > > > > progressive into the range.
    > > > > > Trying stuff like this with no joy.
    > > > > >
    > > > > > Sub FillTest()
    > > > > > With Selection
    > > > > > '.AutoFill Destination = fillRange
    > > > > > '.AutoFill (Destination = fillRange)
    > > > > > 'SourceRange.AutoFill Destination:=fillRange
    > > > > > End With
    > > > > > End Sub
    > > > > >
    > > > > > Sub FillTest()
    > > > > > Selection.AutoFill Destination:=ActiveCell.Range("Want Selected
    > > > > range
    > > > > > here"), _
    > > > > > Type:=xlFillDefault
    > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > > Desert Piranha
    > > > > >
    > > > > >
    > > > >

    > > ------------------------------------------------------------------------
    > > > > > Desert Piranha's Profile:
    > > > > http://www.excelforum.com/member.php...o&userid=28934
    > > > > > View this thread:
    > > > > http://www.excelforum.com/showthread...hreadid=519047
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > >
    > > > --
    > > > Desert Piranha
    > > >
    > > >

    > > ------------------------------------------------------------------------
    > > > Desert Piranha's Profile:

    > > http://www.excelforum.com/member.php...o&userid=28934
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=519047
    > >
    > > --
    > >
    > > Dave Peterson

    >
    > --
    > Desert Piranha
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=519047


    --

    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