Results 1 to 3 of 3

AutoFill to Last Row in Column A

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    AutoFill to Last Row in Column A

    Hello, could some one please help modify the code as shown below so that in column A of worksheet: Data to Text I need an AutoFill from cell A1 to the last row. The value in cell A1 needs to be: 1

    If there are more than 1 records then I need an AutoFill from cell A1 to the last row. However, the value in cell A1 needs to be 1, value in cell A2 needs to be 2, value in cell A3 needs to be 3 etc...

    Any assistance is greatly appreciated.

    Kind regards,

    Chris

    Sub Data_to_Text()
    '
    ' Data to Text Macro
    ' Macro recorded 9/02/2010
    '
    
    '
        Dim myRange As Range
        Dim lr As Long
    
        
        Set myRange = Selection
        
        Sheets("Data").Select
        
        For Each cell In myRange
            Range(cell.Address).Value = cell.Value
        Next cell
        
        Selection.Copy
        
        Sheets("Data to Text").Select
        
        ActiveSheet.Paste
        
        Columns("A:A").Select
        
        Application.CutCopyMode = False
        
        Selection.Insert Shift:=xlToRight
        
        ActiveCell.FormulaR1C1 = "1"
        Range("A2").Select
        ActiveCell.FormulaR1C1 = "2"
                   
        lr = Cells(Rows.Count, "a").End(xlUp).Row
        
        Range("A1:A2").Select
        
        Range(Cells(lr, "a"), Cells(lr, "a")). _
        AutoFill Range(Cells(lr, "a"), Cells(lr + 2, "a"))
               
        
    End Sub
    Last edited by longbow007; 02-11-2010 at 12:32 AM.

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