LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Problem with Find filling a listbox vba

Hi,

I've got a simple problem (I think)

I would like to search within a selection using the find method. Then
transfer the found cells to a listbox.

The problem is that the code I'm using loops a "few times to many".
Does anyone know what's wrong with it?

Here's the code

Private Sub CommandButton2_Click()

Dim sh As Worksheet
Set sh = ThisWorkbook.Worksheets("sheet1")

sh.UsedRange.Activate
cntend = LastRow(sh)


Selection.Find(What:="cash", After:=ActiveCell, LookIn:=xlValues,
Lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=True, SearchFormat:=False).Activate
ActiveCell.Select

counter = 1
Do While counter < cntend

Cells.FindNext(After:=ActiveCell).Activate
ListBox1.AddItem ActiveCell.Value
counter = counter + 1

Loop

End Sub


Help Appreciated,

Farmer

 
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
problem filling in blank cells with data above - stumped-in-excel[_2_] Excel Discussion (Misc queries) 1 July 6th 09 10:10 PM
Where do I find a template for filling out 1099-MISC forms? Anne Troy Excel Discussion (Misc queries) 0 February 13th 06 06:59 AM
Filling down problem in VB kate Excel Programming 2 June 9th 04 03:53 PM
filling a two column listbox from a two column recordset Dennis Excel Programming 5 May 23rd 04 10:13 PM
Filling a listbox depending on font index Trevor[_3_] Excel Programming 0 October 1st 03 08:25 PM


All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"