+ Reply to Thread
Results 1 to 7 of 7

AutoFill cell from above macro

Hybrid View

dtd509 AutoFill cell from above macro 10-10-2007, 12:38 PM
VBA Noob See link ... 10-10-2007, 12:40 PM
dtd509 That is perfect. One question... 10-10-2007, 12:47 PM
dtd509 Maybe a better example is... 10-10-2007, 12:57 PM
VBA Noob See i this helps Sub... 10-10-2007, 01:04 PM
  1. #1
    Registered User
    Join Date
    10-10-2007
    Posts
    11

    AutoFill cell from above macro

    I am looking for a macro that will be able to autofill until it reaches a different value. Once it hits that value can it then autofill until the next value and so on?

    Example:

    A1 Cell : 10/10/2007
    A2-A50 are blank

    A51: 10/11/2007
    A52 - A103 are blank

    The problem is that the number of cells between each of the dates varies. Is there a macro that can be created that will autofill the date (so it would autofill 10/10/2007 until it reaches 10/11/2007, then it would autofill from 10/11/2007 until 10/12/2007 and so on). Any help with this would be appreciated. Thanks for your time.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See link

    http://contextures.com/xlDataEntry02.html

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-10-2007
    Posts
    11
    That is perfect. One question though is there a way to have this autofill to a certain cell number. The code ends at the last date, can this be autofilled farther than that to say a specific cell #?

  4. #4
    Registered User
    Join Date
    10-10-2007
    Posts
    11
    Maybe a better example is that the last date is on 10/15 and it autofills to that date. Can I change the code to autofill to a specific cell past that date.

    Example:

    A1500 - 10/15
    A1501 - 1600 are blank

    Can we set the code to fill to cell A1600 instead of stopping at A1500?

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See i this helps

    Sub FillColBlanks()
    'by Dave Peterson  2004-01-06
    'fill blank cells in column with value above
    Dim wks As Worksheet
    Dim rng As Range
    Dim LastRow As Long
    Dim col As Long
    
    Set wks = ActiveSheet
    With wks
       col = ActiveCell.Column
       'or
       'col = .range("b1").column
    
       Set rng = Cells(1600, ActiveCell.Column) 'try to reset the lastcell
       LastRow = 1600
       Set rng = Nothing
       On Error Resume Next
       Set rng = .Range(.Cells(2, col), .Cells(LastRow, col)) _
                      .Cells.SpecialCells(xlCellTypeBlanks)
       On Error GoTo 0
    
       If rng Is Nothing Then
           MsgBox "No blanks found"
           Exit Sub
       Else
           rng.FormulaR1C1 = "=R[-1]C"
       End If
    
       'replace formulas with values
       With .Cells(1, col).EntireColumn
           .Value = .Value
       End With
    
    End With
    
    End Sub
    VBA Noob

  6. #6
    Registered User
    Join Date
    10-10-2007
    Posts
    11

    Thumbs up

    You rock that is perfect. Thanks again!

+ 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