VBA Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone

I wonder if I could ask for some help on efficient coding?

I have a spreadsheet that is set out much like a table. I have some code in
a module that I call to search the spreadsheet for a value/text. I have
often wondered if there is a better way of coding this as I am using a
looping statment.

Example: I want to look up a part code No. I call the following routine and
pass the public variables (y, x, nam & mylook) to it:

------------------------------------------
Public Sub LookUP()

On Error Resume Next '---just incase----

Do While Check = True
y = y + 1
nam = Cells(y, x).Value
If nam = mylook Then '---if my value/text is found
Check = False
End If

Loop

End Sub
 
Please try this ...

============================
Public Sub lookup1()
On Error Resume Next

With Cells
.Find("Abc").Select
End With

End Sub

============================

Replace "Abc" with your variable.


Please rate me.
 
Thankyou Naveen, That works great!

Naveen said:
Please try this ...

============================
Public Sub lookup1()
On Error Resume Next

With Cells
.Find("Abc").Select
End With

End Sub

============================

Replace "Abc" with your variable.


Please rate me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top