Results 1 to 2 of 2

Require Macro to find cell and copy selection of data to last empty cell in column A

Threaded View

spi Require Macro to find cell... 03-02-2010, 09:09 AM
Leith Ross Re: Require Macro to find... 03-02-2010, 01:23 PM
  1. #1
    Registered User
    Join Date
    03-02-2010
    Location
    dfgh
    MS-Off Ver
    Excel 2003
    Posts
    1

    Require Macro to find cell and copy selection of data to last empty cell in column A

    Here's my problem.

    I have a spreadsheet but all of the data is on the first two rows, the column headers are repeateded when the data is repeated. What I have to do is find a column containing the word Username and then copy the cell below along with the next 12 cells on that row.

    This information has to then be posted in the last blank Cell in column A.

    Here's what I have so far.
    Sub Process()
    '
    ' Process - Opens file
    '
    Workbooks.OpenText Filename:= _
    "C:\Documents and Settings\Owner.ANONYMOUS\Desktop\userlist2.txt", Origin:= _
    437, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
    ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
    , Space:=False, Other:=True, OtherChar:=":", FieldInfo:=Array(Array(1, 1 _
    ), Array(2, 1)), TrailingMinusNumbers:=True
    
    ' transposes content
    
    Range("A1:B55").Select
    Selection.Copy
    Range("D1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Columns("A:G").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Columns("A:G").Select
    Range("G1").Activate
    
    Selection.Delete Shift:=xlToLeft
    Range("A1").Select
    ' Finds User name column
    
    Cells.Find(What:="UserName", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Cells.FindNext(After:=ActiveCell).Activate
    ActiveCell.Offset(1).Select
    
    ' Copies data below
    
    ActiveSheet.Range(Cells(2, 1), Cells(2, 12)).Select
    Selection.Copy
    
    If Range("a1") <> "" Then
    Range("a1").End(xlUp).Offset(1, 0).Select
    Else
    Range("a1").End(xlUp).Select
    
    End If
    
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste
    
    
    End Sub
    If anyone has any comments or questions please don't hesitate to contact me. I would sincerely appreciate any assistance you can give.
    Last edited by Leith Ross; 03-02-2010 at 12:30 PM. Reason: Added Code Tags

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