seraching a certain range

G

Guest

I search parts of a spreadsheet for certain words etc. My code looks like:

Set searchRange = Range(Cells(rng5.Row, 1), Cells(rng5.Row, 100))
Set rng2 = Worksheets("Beräkning").Range(searchRange.Address).Find("Date",
LookIn:=xlValues)

and this works fine. I just wonder is it not possible to write the code in a
shorter way by writing something like eg.

Set rng2 = Worksheets("Beräkning").searchRange.Find("Date", LookIn:=xlValues)

It does not work for me when I write it like that. what am i doing wrong?
Thanks
 
M

MattShoreson

If the first way works then use it.

Re-factoring for the sake of it (i.e. to use less lines/words) is no
worth it.

Re-factor to chop up re-usable code, create classes etc
 
D

Don Guillett

a bit simpler perhaps
x=Worksheets("sheet2").Range("a1:h13").Find("date").Address
End With
 

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

Similar Threads

Search parts of a spreadsheet 1
Search parts on a spreadsheet 3
Freeze pane 3
Locking panes 1
Looper blooper 1
Select every cell that has a certain value 1
Looper blooper 3
Macro to Change a Range 12

Top