Results 1 to 7 of 7

Autofill selection down to last row

Threaded View

  1. #1
    Registered User
    Join Date
    11-01-2011
    Location
    Twente, Nederland
    MS-Off Ver
    Excel Professional Plus 2019
    Posts
    40

    Autofill selection down to last row

    Hi,

    I have a macro, that will add records to my table using vertical lookup formulas in several columns from data in another worksheet.
    Before I run the macro, I add the record-id's for the new records in column A.
    Then I run the macro.
    Everything runs smoothly, until the Autofill copies the formulas from the first new record down to the last new record.

    What do I need to change in the code, to make the autofill do it's job correctly?
    Attached are two Screenshots. One with my code (snap2.jpg) and one with a view of part of my table (snap1.jpg)
    Snap1.jpg
    Snap2.jpg.
    Sub Gegevens_uit_Sapdump_ophalen()
        Dim LastRow1 As Long
        LastRow1 = Range("A" & Rows.Count).End(xlUp).Row
        Range("A" & LastRow1).Select
        Range(Selection, Selection.End(xlUp)).Select
        ActiveCell.Select
        ActiveCell.Offset(0, 3).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,6,0)"
        ActiveCell.Offset(0, 1).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,3,0)"
        ActiveCell.Offset(0, 6).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,7,0)"
        ActiveCell.Offset(0, 3).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,10,0)"
        ActiveCell.Offset(0, 1).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,11,0)"
        ActiveCell.Offset(0, 3).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,14,0)"
        ActiveCell.Offset(0, 3).Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,art_StoreServer.txt!C1:C15,2,0)"
        Range("D" & LastRow1).Select
        Range(Selection, Selection.End(xlUp)).Select
        ActiveCell.Select
        Range(ActiveCell, ActiveCell.Offset(0, 17)).Select
        Selection.AutoFill Destination:=Range(Selection & LastRow1)
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Columns("A:D").Select
        Selection.EntireColumn.Hidden = False
    End Sub
    Last edited by pluginguin; 11-02-2011 at 11:34 AM. Reason: VBA-code requested

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