Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2005, 12:51 PM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default error 400

I have the below code which is sorting a range of data and then inserting a row at each change in column A. The code is working however, at the end of the procedure I am getting an error 400 and I don't know why. The code is below. Thanks for the help.

Public Sub copyrange()
On Error GoTo 0
 Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
Dim i As Long
    Dim lastrow As Variant
Application.ScreenUpdating = False
lastrow = Range("a65536").End(xlUp).Row


For i = lastrow To 1 Step -1
    If Cells(i, "A") <> Cells(i - 1, "A") Then
        Rows(i).Insert
   End If
Next i

Application.ScreenUpdating = True

End Sub

 
Old October 1st, 2005, 02:40 PM
Authorized User
 
Join Date: Aug 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

David

1. What is the exact description for error 400?
2. It helps to set up the whole picture for us first: What are you inserting rows into (Excel, datagrid, etc.)?
3. The last for next-loop is checking against Cells(i - 1) which on i=1 would be 0. Does the Cells collection have a valid Row(0)? If not, that is your problem.






Similar Threads
Thread Thread Starter Forum Replies Last Post
AS/400 gagiovla SQL Server 2000 8 October 2nd, 2009 11:22 AM
What Is Error 400? RollingWoodFarm Excel VBA 3 January 2nd, 2007 03:07 PM
Reg :400 Error in Web Services sriram6781 XML 1 August 8th, 2005 07:59 PM
XML & AS/400 jmariani XML 1 November 7th, 2003 04:01 AM
Using XMLHTTP in VBA - Error 400 helentoomik XML 3 July 17th, 2003 04:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.