Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default error 400, i cant figure this out..

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default error 400, i cant figure this out..

Tom, Im not getting what you gave me to work as well, im very new to visual
basic. The code you posted below gives me errors when i put it in, i get
syntax error with this line

set rng = .Range(.Range("B4'), _
.Range("B4").End(xldown))



"Tom Ogilvy" wrote:

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




  #4   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default error 400, i cant figure this out..

Michael,

try to change it to:

set rng = .Range(.Range("B4"), _
.Range("B4").End(xldown))

Regards,
KL


"Michael A" wrote in message
...
Tom, Im not getting what you gave me to work as well, im very new to
visual
basic. The code you posted below gives me errors when i put it in, i get
syntax error with this line

set rng = .Range(.Range("B4'), _
.Range("B4").End(xldown))



"Tom Ogilvy" wrote:

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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default error 400, i cant figure this out..

According to Help, the message for Error 400 is "Form already displayed; can't
show modally". Are you sure that's the error number? On which line to you get
the error? Have you checked that the entries in column B correspond EXACTLY
with the sheet names? The following shows you one way to trap that error.

Notice, that as in the other code you were given, you don't need to select
and/or activate worksheets and cells to copy and paste.

Option Explicit

Sub Macro1()
Dim DestCell As Range
Dim DestSheet As String
Dim i As Long
Dim SrcCell As Range

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

For Each SrcCell In ActiveSheet.Range("B5", Cells(65536, 2).End(xlUp))
DestSheet = SrcCell.Value
If DestSheet = "" Then Exit For 'embedded blank cell -- quit

On Error Resume Next
i = Worksheets(DestSheet).Index
If Err.Number < 0 Then
MsgBox _
"There is no worksheet named '" & DestSheet & "'!", _
vbCritical + vbOKOnly
Exit For
End If
On Error GoTo 0

With Worksheets(DestSheet)
Set DestCell = .Cells(1, 1).End(xlDown)
If DestCell.Row = 26 Or DestCell.Row = 65536 Then
Set DestCell = .Cells(2, 1)
Else
Set DestCell = DestCell.Offset(1, 0)
End If
End With
SrcCell.EntireRow.Copy DestCell
Next SrcCell

With Application
.CutCopyMode = False
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub



On Sun, 6 Mar 2005 14:21:02 -0800, Michael A
wrote:

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


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
Can't figure this out... jmj713 Excel Discussion (Misc queries) 8 April 11th 09 02:33 AM
HOW TO 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Excel Worksheet Functions 3 December 30th 08 03:04 PM
Can't figure this out!!! Tilleyswife Excel Worksheet Functions 3 November 9th 06 06:21 PM
Some Error that I can't figure out. Mcobra41 Excel Discussion (Misc queries) 1 February 28th 05 11:42 PM
help me figure out this buG? majikman[_23_] Excel Programming 2 May 17th 04 11:30 AM


All times are GMT +1. The time now is 10:05 AM.

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"