Results 1 to 2 of 2

VBA code to add column at the end of sheet

Threaded View

  1. #1
    Registered User
    Join Date
    02-18-2004
    Posts
    55

    VBA code to add column at the end of sheet

    Quick question....I've recorded a simple macro to insert (2) columns at the end of a data set and autofill them down with the value of "1".

    My question is, my data set is dynamic and my last column may not always be "S", how can I force it to the last column in the sheet...Thanks in advance...

    CODE SNIP
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Range("Table2[[#Headers],[AccountTypeDescription]]").Select
        Selection.End(xlToRight).Select
        Range("S1").Select
        ActiveCell.FormulaR1C1 = "Work"
        Range("T1").Select
        ActiveCell.FormulaR1C1 = "QTY"
        Range("S2").Select
        ActiveCell.FormulaR1C1 = "1"
        Range("T2").Select
        ActiveCell.FormulaR1C1 = "1"
        Range("S2").Select
        Selection.AutoFill Destination:=Range("Table2[Work]")
        Range("Table2[Work]").Select
        Range("T2").Select
        Selection.AutoFill Destination:=Range("Table2[QTY]")
        Range("Table2[QTY]").Select
    End Sub
    Last edited by pjw23; 11-27-2012 at 01:48 PM.

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