Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

Hi

Im not quite sure what Im doing wrong...

Based on a value in a list box, I want to insert a row in the prope
alphabetical order.

This is what I have:

Private Sub CmdUpdateNew_Click()

Sheet2.Activate
Sheet2.Range("A4").Select

For i = 4 To Range("A65536").End(xlUp).Row
If Range("A" & i) Value ListNew.Value And
Range("A" & i - 1).Value < ListNew.Value Then
Rows(i).Insert
Exit For
End If
Next i


End Sub

Any ideas or help will be REALLLY appreciated!

Thanks!
Sheen

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

Why not just paste it at the end, then sort the column:

Private Sub CmdUpdateNew_Click()

Sheet2.Activate
Sheet2.Range("A4").Select

Range("A" & Range("A65536").End(xlUp).Row+1).Value = ListNew.Value

Range("A4:A" & Range("A65536").End(xlUp).Row).Select
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlNo

Range("A4").Select

End Su

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

Hi
thanks for that tip but for some reason it gives me an error...

The debugging tool points to this line:

Range("A4:A" & Range("A65536").End(xlUp).Row).Select

Any ideas

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

I tested it on my machine Win2K, Excel 2002 with no problems. I cannot
think what the error might be... If you didn't cut/paste, there may be
a typo in your code? Possible a space somewhere in the Range
function?

I'm at a loss...

K


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

That might be the problem - Im using Excel 2000

THanks

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting a row

It shouldn't matter if the line:

Range("A" & Range("A65536").End(xlUp).Row+1).Value = ListNew.Value

works. It is essentially doing the same thing...



--
Message posted from http://www.ExcelForum.com

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
Inserting a zero Janice Excel Discussion (Misc queries) 5 August 15th 08 01:31 PM
inserting row GARY Excel Discussion (Misc queries) 3 April 28th 08 11:26 AM
Inserting a row below Belgarth Excel Discussion (Misc queries) 1 January 23rd 06 07:48 PM
Inserting a row Lee Excel Programming 1 February 19th 04 08:10 PM
Inserting a Row with VBA Thomas M Excel Programming 7 November 29th 03 05:33 AM


All times are GMT +1. The time now is 12:57 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"