View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default error 400, i cant figure this out..

Sub Macro1()
Dim rng as Range
With Activesheet
set rng = .Range(.Range("B4'), _
.Range("B4").End(xldown))
End With
for each cell in rng
cell.EntireRow.copy Destination:= _
worksheets(cell.value) _
.Cells(rows.count,1).End(xlup)(2)
Next
Application.CutCopyMode = False
End Sub

I can't figure out what the row = 26 select A2 step is supposed to do.

--
Regards,
Tom Ogilvy


"Michael A" wrote in message
...
I get error 400 when i run this, I cant figure out whats causing it, can
anyone help please? What it should be doing is copying all the lines on

the
sheet to there own proper sheets, using the value in the B column as the
sheet name, it should be copying them starting in the first row that is
unused. Thanks so much!


Sub Macro1()
ThisSheet = ActiveSheet.Name
Range("B4").Select
ActiveCell.Offset(1, 0).Range("A1").Select
Do Until ActiveCell.Value = ""
ToSheet = ActiveCell.Value
ActiveCell.EntireRow.Copy
Sheets(ToSheet).Select
Range("A1").Select
Selection.End(xlDown).Select
If ActiveCell.Row = 26 Then
Range("A2").Select
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
ActiveSheet.Paste
Sheets(ThisSheet).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
Application.CutCopyMode = False
End Sub