Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default 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").E nd(xlUp).Offset(1,
0)


Next oCell


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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" wrote in message
...
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").E nd(xlUp).Offset(1, 0)
Next oCell


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default 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).Offs et(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").E nd(xlUp).Offset(1,
0)


Next oCell


End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro - modification yshridhar Excel Discussion (Misc queries) 10 February 1st 08 03:47 AM
Macro Modification carl Excel Worksheet Functions 0 May 4th 07 04:17 PM
Macro Code minor alteration please. RPTZ New Users to Excel 6 July 10th 05 05:47 AM
Need Macro Modification Phil Hageman[_3_] Excel Programming 2 June 2nd 04 12:26 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"