Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting a row
That might be the problem - Im using Excel 2000
THanks -- Message posted from http://www.ExcelForum.com |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting a zero | Excel Discussion (Misc queries) | |||
inserting row | Excel Discussion (Misc queries) | |||
Inserting a row below | Excel Discussion (Misc queries) | |||
Inserting a row | Excel Programming | |||
Inserting a Row with VBA | Excel Programming |