+ Reply to Thread
Results 1 to 3 of 3

autofill a range

  1. #1
    Registered User
    Join Date
    02-17-2005
    Posts
    2

    autofill a range

    hi

    the following code works for me:

    var1 = 6 + Range("E2").Value
    Range("A6:E6").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("A6:E41"), Type:=xlFillDefault


    except; I do'nt want to fill range A6 to E41 but I want to fill range A6 to E(var1) or in other words; fill range A6 to E( 6+ value in field E2)

    hope you can help

    thanks in advance

    henkie

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Henkie,

    Like the way you think. I often use this method. It quite easy to do and very flexible.
    _________________________________________________________________

    Change your code to this:

    var1 =Ltrim(Str( 6 + Range("E2").Value))
    Range("A6:E"&var1).Select

    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("A6:E"&var1), Type:=xlFillDefault

    _________________________________________________________________

  3. #3
    Registered User
    Join Date
    02-17-2005
    Posts
    2

    thanks

    Thanks,

    works great except for one thing;

    The first range should be just A6 to E6 and NOT A6 to E + var1


    var1 = LTrim(Str(6 + Range("E2").Value))
    Range("A6:E6").Select
    Application.CutCopyMode = False
    Selection.AutoFill Destination:=Range("A6:E" & var1), Type:=xlFillDefault

    Thanks for your help

    henkie

+ 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