+ Reply to Thread
Results 1 to 3 of 3

range selection for autofill

Hybrid View

  1. #1
    Registered User
    Join Date
    06-06-2008
    Posts
    2

    range selection for autofill

    hey, I have some noobiesh question, it's probably been answered before in some way but I have been searching it but haven't been able to find it.

    I want to autofill some range with some formula and I'm using these lines.

    Selection.AutoFill Destination:=Range("B1:B10"), Type:=xlFillDefault
    Range("B1:B10").Select
    only I would like to be able to adjust the range depending on the size of the dataset. so I would to be able to set a number in a cell i.e. A1=20 so that the code changes to

    Selection.AutoFill Destination:=Range("B1:B20"), Type:=xlFillDefault
    Range("B1:B20").Select
    Last edited by LuuKoO; 06-06-2008 at 05:49 AM.

  2. #2
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    try this one

    Sub autofill()
        Dim i As Long
        i = InputBox("Enter the last row number")
        
        Selection.autofill Destination:=Range(Cells(1, 2), Cells(i, 2)), Type:=xlFillDefault
        Range(Cells(1, 2), Cells(i, 2)).Select
    
    End Sub

  3. #3
    Registered User
    Join Date
    06-06-2008
    Posts
    2
    that was really helpfull, thanks a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Range selection based on adjacent cell range
    By iguss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-20-2008, 07:57 AM
  2. cell selection in a given column range ?
    By cantabile in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2007, 10:09 PM
  3. simple range selection query
    By nickbarthram in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2007, 10:52 AM
  4. Range Selection problem
    By Coolboy55 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2007, 12:58 PM
  5. create a form that allows selection of a range
    By laureenl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2006, 04:25 AM

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