+ Reply to Thread
Results 1 to 5 of 5

Autofill macro: filling for range whilst there is a value in cell

Hybrid View

  1. #1
    Registered User
    Join Date
    09-12-2007
    Posts
    24

    Autofill macro: filling for range whilst there is a value in cell

    Hi!

    I'm pretty new to macros. I recorded one for an autofill series which basically came out as

    Selection.AutoFill Destination:=Range("I2:I8"), Type:=xlFillDefault
    However, what I really want is for the range to go from I2 and go down for every cell whilst there is a value in the cell to the left (i.e. I2:End)

    Anyone know how this can be done?

    Thanks in advance!
    Last edited by maff; 11-25-2008 at 07:35 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    See this code that I just posted in this thread
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-12-2007
    Posts
    24
    Cheers for the reply Roy. Unfortunately I haven't explained my self very well.

    Basically this macro will be used on adifferent sheets sent by my suppliers every week. It is a list of prices of things I have bought from them for that week. Someweeks O have bought 50 things. Others 100 etc. I am creating the macro to calculate my prices based on the price they send.

    Therefore there is the "supplier price" column and to the right "My Price". I want the macro to copy the forumula in the first cell of "My Price" and run down the column until the final product. Like I say, sometimes it is 100, sometimes more. Sometimes less.

    Am I making sense?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You only need to hover the cursor over the bottom right corner of the formula cell until it changes to a crosshair (+), then doubleclick.

  5. #5
    Registered User
    Join Date
    09-12-2007
    Posts
    24
    I know but this is one part of a very long sequence of things I need to do to the sheet before printing.

    I've done it though based upon the lngRows function you gave me:

    Dim lngRows As Long
    lngRows = Range("H2").CurrentRegion.Rows.Count
    
    ' Add my Prices
    Selection.AutoFill Destination:=Range("I2:I" & lngRows), Type:=xlFillDefault
    Cheers!

+ 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