PDA

View Full Version : Solved: Using find function



suddenflash
05-03-2012, 10:57 AM
Hi!

I am trying to write code which has to find string combination " Rh" in a cell. Cells are in cycle so the whole coloumn will be searched.

Somehow I get an error message - Object required, but I have refferred to worksheet ... Can someone help me please


Sub otsib rh()
Dim i As Integer
Dim otsi As String
Dim rida As String
i = 0
Do While i < 100
i = i + 1
rida = " Rh"
Set otsi = Worksheets(1).Cells(i, 2).Find(rida, MatchCase:=False)
' just for checking if the code works
`If Not otsi Is Nothing Then
Cells(i, 10).Value = 10
Loop
End Sub

Many thanks ahead

Tinbendr
05-03-2012, 12:21 PM
Sub otsibrh()
Dim i As Integer
Dim otsi As Range
Dim rida As String
i = 0
Do While i < 100
i = i + 1

rida = " Rh"

Set otsi = Worksheets(1).Cells(i, 2).Find(rida, MatchCase:=False)

' just for checking if the code works
If Not otsi Is Nothing Then
Cells(i, 10).Value = 10
End If
Loop
End Sub

suddenflash
05-03-2012, 12:37 PM
Preciate very much!

I changed worksheet to activsheet works better :)