View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Userforms/Macro search

Why - adding cells in this case doesn't do anything different.

--
Regards,
Tom Ogilvy

"papou" wrote in message
...
Hello
Rog is right but I would also suggest you modify:
For Each r in Range("C2:C" & Range("A65535").End(xlUp).Row).Cells

HTH
Cordially
Pascal

"James Batley" a écrit dans le

message
de ...
I asked about this problem earlier and got a response(see
below for code and request for help) but I cannot get it
to work. I get an error msg saying "For Each can only
iterate over a collection object or an array"

Can anyone suggest a way of fixing this?

Thank you

James
----------------------------------------------------------
Should be fairly simple.

1. Get the selected ITEM from the listbox.
2. Search through all items in the first column for the
value (assuming
column 1 starting with row 1).
3. When found, set the text boxes to the values in columns
F and G (6 &
7) for the row it was found and then exit.
-----------------------------------------------------------

Sub GetDetails_Click()

Dim r as Range
Dim strFind as String
strFind = SiteSelected.Text

For Each r in Range("C2:C" & Range("A65535").End
(xlUp).Row
If r.Value = strFind Then
ProjNo.Text = Range("AS" & r.row).Value
ProjTitle.Text = Range("AT" & r.row).Value
ProjDate.Text = Range("AU" & r.row).value
ProjLat.Text = Range("AP" & r.row).Value
ProjLong.Text = Range("AQ" & r.row).Value
Exit For
End If
Next

End Sub
-----------------------------------------------------------

I have a large spreadsheet with lots of columns. I have
designed a UserForm to Help me select information to look
at. I have categorized the items and can fill list & text
boxes with "stage one" data. There are no two entries the
same.

What I want to do is push a button and populate some list
boxes with "stage two" data. I think that this involves a
search in the first column to find the item and then some
method to bring in the data from the same row but several
columns to the right.

ITEM COL2 COL3 COL4 COL5 INFO1 INFO2


Seach for a specific item then fill box 1 and 2 with INFO1
and INFO2 respectively.

I have spent 5hours today trying to do this and failed
miserably.

Can anyone help???

Thanks James