+ Reply to Thread
Results 1 to 4 of 4

Moving The Selected Record From One Sheet To Another

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Moving The Selected Record From One Sheet To Another

    Hi everybody,

    I have a sheet contains lots of records, some of these records are old and not needed , so I want to transfer them to another sheet in order to go back to them in the future.

    I would like you please to provide me with a VBA code works on moving the whole record to the other sheet when I select any cell of that record>

    I hope that my question is clear for you,

    thank you,
    Last edited by LoveCandle; 01-03-2006 at 03:19 AM.

  2. #2
    Karthik Bhat - Bangalore
    Guest

    Re: Moving The Selected Record From One Sheet To Another

    Hi
    Here is piece of VB code to solve ur problem. Hope you are able to put
    this code in your file and run it.

    Just copy paste the following code in your workbook module in Visual
    Basic Editor available under Tools>Macros> Visual Basic Editor.

    Now go to the sheet that contains the data and double click any cell in
    your old record (I have assumed that you have one record in one row).
    This record is cut from this sheet and pasted in the next sheet.
    Please note that this code will suppress the double click function in
    this excel file of yours. Also make sure that the sheet following your
    data sheet is a new sheet; as it's this new sheet where old records
    will be dumped. And before you start take a backup of ur original file.


    Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
    Target As Range, Cancel As Boolean)
    Rows(ActiveCell.Row).Select
    Selection.Cut
    ActiveSheet.Next.Select
    ActiveSheet.UsedRange.SpecialCells(xlLastCell).Select
    Row = ActiveCell.Row + 1
    Range("A" & Row).Select
    ActiveSheet.Paste
    Range("A" & Row).Select
    Application.CutCopyMode = False
    ActiveSheet.Previous.Select
    Selection.Delete Shift:=xlUp
    ActiveCell.Select
    End Sub


    Thanks Karthik Bhat


  3. #3
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280
    Thank you for ur reply,

    I tested the code you delivered but it stops at the following line:

    Range("A" & Row).Select

    On another hand, I think the code you delivered works on cutting the whole row and paste it in another sheet, while I want the code to copy the current record and paste it in the other sheet then clearing the contents of the copied record in order for me re-fill it again.

    I hope that you got my point.

    Thanks,

  4. #4
    Karthik Bhat - Bangalore
    Guest

    Re: Moving The Selected Record From One Sheet To Another

    Hi

    Try this

    Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
    Target As Range, Cancel As Boolean)
    Rows(ActiveCell.Row).Select
    Selection.Cut
    ActiveSheet.Next.Select
    ActiveSheet.UsedRange.SpecialCells(xlLastCell).Select
    Row = ActiveCell.Row + 1
    Cells(Row, 1).Select
    ActiveSheet.Paste
    Cells(Row, 1).Select
    Application.CutCopyMode = False
    ActiveSheet.Previous.Select
    'Selection.Delete Shift:=xlUp
    'ActiveCell.Select
    End Sub

    Thanks
    Karthik Bhat


+ Reply to Thread

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