Results 1 to 6 of 6

autofill to variable destination

Threaded View

  1. #1
    Registered User
    Join Date
    04-26-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    18

    autofill to variable destination

    I have the following code that was achieved using the macro recorder. The only problem I am running into is that during the autofill command, there are never the same amount of rows to autofill. It could be as few as 5 rows and as many as there are rows on the spreadsheet. When I recorded the macro there were 953 lines, and unfortunately I cannot figure out how to change the specific destination of 953 to a variable destination determined by when data ends.

    Here is the code I currently have:
    Sub ConcatenateHighlight()
    '
    ' ConcatenateHighlight Macro
    '
    
    '
        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("C1").Select
        ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],RC[-1])"
        Range("C1").Select
        Selection.AutoFill Destination:=Range("C1:C953")
        Range("C1:C953").Select
        Range("F1").Select
        ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-2],RC[-1])"
        Range("F1").Select
        Selection.AutoFill Destination:=Range("F1:F953")
        Range("F1:F953").Select
        Range("C:C,F:F").Select
        Range("F1").Activate
        Selection.FormatConditions.AddUniqueValues
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        Selection.FormatConditions(1).DupeUnique = xlDuplicate
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = False
        Range("D1").Select
    End Sub
    Thanks!
    Last edited by katmison; 08-30-2009 at 06:58 PM. Reason: to mark as solved

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