+ Reply to Thread
Results 1 to 8 of 8

Autofill up to last cell of Range

  1. #1
    Registered User
    Join Date
    08-23-2007
    Posts
    58

    Autofill up to last cell of Range

    Hello,

    I've created a named Range called "AutoFill" within column H20:H40

    How can I apply an auto count (autofill?) sequence (1,2,3,4....20) from the first cell begining with 1, up to the last cell of this range, using a VBA script?

    ** Rows will be continually added & deleted within my worksheet, so the position & length of this range will vary.

    Thanks for any help


    Jeff

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Autofill up to last cell of Range

    First, it's a BAD idea to name ranges (or pretty much anything else) with an Excel object, method, or property name. It makes the code more difficult to read and can have unintended consequences.

    Examples:
    A sheet named "sheet"
    a range named "select"...or "AutoFill"

    In your situation, I'd name the range rngAutoFill

    See if this works for you
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    09-20-2006
    Location
    Poland
    Posts
    46
    Hi,

    Quote Originally Posted by jeff.p
    I've created a named Range called "AutoFill" within column H20:H40
    How can I apply an auto count (autofill?) sequence (1,2,3,4....20) from the first cell begining with 1, up to the last cell of this range, using a VBA script?
    Try something like that:

    Please Login or Register  to view this content.
    MS Excel Games Library and much more:
    http://www.dzikosoft.com/gmexcel

  4. #4
    Registered User
    Join Date
    08-23-2007
    Posts
    58
    Thanks, Ron, Bartek!

    Both codes worked wonderfully.

    ...

    If I could possibly ask one more question?

    As a follow up to my initial quarry... How could I use he same scenario.. ie: A range called AutoFill H20:H40, but in this case, rather than fill with a sequential number, to autofill with a single word. "Act01"

    eg:

    Act01
    Act01
    Act01
    Act01
    Act01
    Act01

    etc..


    Thanks again for the help

    Jeff

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Autofill up to last cell of Range

    Try this line of code:

    Please Login or Register  to view this content.
    Does that help?

  6. #6
    Registered User
    Join Date
    08-23-2007
    Posts
    58
    Thanks, Ron

    Tried pasting this into a module, but received this error:

    Run-time error 424
    object required

    any ideas?

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Autofill up to last cell of Range

    Yeah.....sloppiness on my part (sorry)

    Range("AutoFill").Value = "Act01"
    or
    Range("H20:H40").Value = "Act01"

    Does that help?

  8. #8
    Registered User
    Join Date
    08-23-2007
    Posts
    58
    Thanks, Ron!


    ...it helps indeed!



+ 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