Consulting

Results 1 to 2 of 2

Thread: VBA lookup and delte

  1. #1

    VBA lookup and delte

    Hi I have read about the vlookup fomulas but I need it slightly diffrent.

    I need it to look up a member number on the active sheet (sheet database) in cell b3 then it needs to go to my other sheets called database and it should go and delete that row.

    This is my code but I need this code at the bottom
    [VBA]Sub Archive()
    '
    ' Archive Macro
    '

    '
    Range("B2").Select
    Selection.Copy
    Sheets("Archive").Select
    Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A26").Select
    Sheets("Database").Select
    Range("B6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Archive").Select
    Range("b" & Cells(Rows.Count, "b").End(xlUp).Row + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Database").Select
    Range("B13").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Archive").Select
    Range("c" & Cells(Rows.Count, "c").End(xlUp).Row + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Database").Select
    Range("A15").Select
    Application.CutCopyMode = False

    End Sub[/VBA]



    Many Thanks
    David
    Last edited by Bob Phillips; 02-12-2013 at 04:32 AM. Reason: Added VBA tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]Sub Archive()
    Dim lastrow As Long

    With Sheets("Archive")

    lastrow = .Cells(.rows.Count, "A").End(xlUp).Row
    Worksheets("Database").Range("B2").Copy .Range("A" & lastrow + 1)

    lastrow = .Cells(.rows.Count, "B").End(xlUp).Row
    Worksheets("Database").Range("B6").Copy .Range("B" & lastrow)

    lastrow = .Cells(.rows.Count, "C").End(xlUp).Row
    Worksheets("Database").Range("B13").Copy .Range("c" & lastrow)
    End With

    Workheets("Database").rows(3).Delete
    End Sub[/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •