View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tendresse Tendresse is offline
external usenet poster
 
Posts: 117
Default select a cell with specific value

Hi Gary, thank you very much for your generosity, much appreciated. :)

I tried your code and it works very well. However, there is still one small
bit needed in the

The ID numbers i have in the range look like this:
FP1111
FP1112
FP1113 , etc


In the InputBox, when i entered part of a number (for example FP11), the
code selected the first cell with a value starting with FP11. I was expecting
to get the message saying that the number is not found.

How do i look for the EXACT MATCH?

"Gary Keramidas" wrote:

try this, i feel a little generous tonight.

Sub homework_assignment()
Dim rng As Range, rngfound As Range
Dim idNumber As Double

idNumber = 6
Set rng = Range("c15:c100")
With rng

Set rngfound = .Find(idNumber, LookIn:=xlValues)
If Not rngfound Is Nothing Then
rngfound.EntireRow.Offset(1).Resize(9).Select
Else
MsgBox "ID Number " & idNumber & " not found"
End If
End With

End Sub

--


Gary


"Tendresse" wrote in message
...
hi all, i'm stuck and need some help, please.
How do you say the following in VBA?

In range("C15:C100"), find the cell that contains the value 'IDNumber' and
select the entire row where this cell is, and extend the selection to include
the following 9 rows below the cell. If the IDNumber not found, prompt the
user that number not found.

(NB: IDNumber is a variable that the user will enter through an inputBox
earlier in the code. The IDNumber is a unique number, it will only appear
once in the range specified above, or it won't appear at all. But in anycase,
the same number won't appear twice in the range.)

i'm using Excel 2003

Many thanks
Tendresse