+ Reply to Thread
Results 1 to 4 of 4

minor modification to macro, need to delete cells

  1. #1
    Michael A
    Guest

    minor modification to macro, need to delete cells

    can someone help me add to his macro, after it copys each line I need it to
    delete the values in the A Column , E Column and F column, but i cant figure
    it out.. anyone help would be appreciated. Thanks!


    Sub CopyToSheetz()

    Dim rng As Range
    Dim oCell As Range

    Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    For Each oCell In rng
    oCell.EntireRow.Copy _
    Destination:=Sheets(oCell.Value).Range("A65536").End(xlUp).Offset(1,
    0)


    Next oCell


    End Sub


  2. #2
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    I'd try this

    Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    For Each oCell In rng
    oCell.EntireRow.Copy _
    Destination:=Sheets(oCell.Value).Range("A65536").End(xlUp).Offset(1,
    0)
    cells(ocell.row,1).clearcontents
    cells(ocell.row,5).clearcontents
    cells(ocell.row,6).clearcontents
    Next oCell
    not a professional, just trying to assist.....

  3. #3
    Jim Cone
    Guest

    Re: minor modification to macro, need to delete cells

    Michael,

    This seems to work...
    '---------------------------------------------
    Sub CopyToSheetz()
    Dim rng As Range
    Dim oCell As Range
    Dim lngCell As Long

    lngCell = Cells(Rows.Count, 2).End(xlUp).Row

    Set rng = Range(Cells(4, 2), Cells(lngCell, 2))
    For Each oCell In rng
    oCell.EntireRow.Copy _
    Destination:=Sheets(oCell.Value).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    Next oCell
    Range(Cells(4, 1), Cells(lngCell, 1)).ClearContents
    Range(Cells(4, 5), Cells(lngCell, 6)).ClearContents
    End Sub
    '--------------------------------------------

    Jim Cone
    San Francisco, USA



    "Michael A" <[email protected]> wrote in message
    news:[email protected]...
    > can someone help me add to his macro, after it copys each line I need it to
    > delete the values in the A Column , E Column and F column, but i cant figure
    > it out.. anyone help would be appreciated. Thanks!
    >
    >
    > Sub CopyToSheetz()
    >
    > Dim rng As Range
    > Dim oCell As Range
    >
    > Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    > For Each oCell In rng
    > oCell.EntireRow.Copy _
    > Destination:=Sheets(oCell.Value).Range("A65536").End(xlUp).Offset(1, 0)
    > Next oCell


    > End Sub



  4. #4
    gocush
    Guest

    RE: minor modification to macro, need to delete cells

    Michael,
    Not sure from you post if you want to clear cell A,E & F in the source sheet
    or the destination sheet. Below is guessing the Dest sheet.

    Sub CopyToSheetz()

    Dim rng As Range
    Dim oCell As Range
    Dim Dest as Range

    Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    For Each oCell In rng
    Set Dest = Sheets(oCell.Value).Range("A65536").End(xlUp).Offset(1,
    0)
    oCell.EntireRow.Copy Dest
    'Clear cell A,E, and F
    Dest.Clearcontents
    Dest.Offset(0,4).ClearContents
    Dest.Offset(0,5).ClearContents

    Next oCell

    Set Dest = Nothing
    Set Rng = Nothing
    Set oCell = Nothing
    End Sub


    "Michael A" wrote:

    > can someone help me add to his macro, after it copys each line I need it to
    > delete the values in the A Column , E Column and F column, but i cant figure
    > it out.. anyone help would be appreciated. Thanks!
    >
    >
    > Sub CopyToSheetz()
    >
    > Dim rng As Range
    > Dim oCell As Range
    >
    > Set rng = Range("B4:B" & Cells(Rows.Count, "B").End(xlUp).Row)
    > For Each oCell In rng
    > oCell.EntireRow.Copy _
    > Destination:=Sheets(oCell.Value).Range("A65536").End(xlUp).Offset(1,
    > 0)
    >
    >
    > Next oCell
    >
    >
    > End Sub
    >


+ 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