Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default listbox not updating

hello,

i am new to this site but i need some help. i have a userform with a
listbox on it. the list box has 20 columns and upto 200 rows.

i populate the list box via the row source property.

i want to click on a row within the list and delete it. i can do this
as i find the row i am on by setting a variable to the list control
source which i have set elseware on another worksheet.

i have this code assigned to a command button on the form

sub deleterow ()
dim rgstack as range
clears = worksheets("sheet2").Range("a1")
Set rgstack = worksheets("sheet1").Range("a1:a2000").Find(what:= clears)
rgstack.EntireRow.Delete Shift:=xlUp
end sub


now here is the real problem, this code works fine on xl2000 but on
xl97 it works once then the second time the row does not disapear.

is it a code compatibility issue or is there a better way of updating a
list when deleting a row

regards
tammy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default listbox not updating

I don't have xl97 to test it on, but maybe you could use a different technique.

Just delete the row that's selected and then refresh the listbox.

Option Explicit
Dim myRowSourceRange As Range
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
With Me.ListBox1
If .ListIndex -1 Then
'something is selected
myRowSourceRange.Cells(1, 1).Offset(.ListIndex).EntireRow.Delete
End If
End With
Call UserForm_Initialize
End Sub
Private Sub UserForm_Initialize()
With Worksheets("sheet1")
Set myRowSourceRange = .Range("a1:H" & .Cells(.Rows.Count,
"A").End(xlUp).Row)
With Me.ListBox1
.ColumnCount = 8 'for testing
.RowSource = myRowSourceRange.Address(external:=True)
End With
End With
End Sub



wrote:

hello,

i am new to this site but i need some help. i have a userform with a
listbox on it. the list box has 20 columns and upto 200 rows.

i populate the list box via the row source property.

i want to click on a row within the list and delete it. i can do this
as i find the row i am on by setting a variable to the list control
source which i have set elseware on another worksheet.

i have this code assigned to a command button on the form

sub deleterow ()
dim rgstack as range
clears = worksheets("sheet2").Range("a1")
Set rgstack = worksheets("sheet1").Range("a1:a2000").Find(what:= clears)
rgstack.EntireRow.Delete Shift:=xlUp
end sub

now here is the real problem, this code works fine on xl2000 but on
xl97 it works once then the second time the row does not disapear.

is it a code compatibility issue or is there a better way of updating a
list when deleting a row

regards
tammy


--

Dave Peterson
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
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Multicolumn Listbox and ordinary listbox Ron_D Excel Programming 0 June 4th 04 08:56 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


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