Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
seraching a certain range
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
seraching a certain range
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 -- MattShoreso ----------------------------------------------------------------------- MattShoreson's Profile: http://www.excelforum.com/member.php...nfo&userid=347 View this thread: http://www.excelforum.com/showthread.php?threadid=56328 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
seraching a certain range
a bit simpler perhaps
x=Worksheets("sheet2").Range("a1:h13").Find("date" ).Address End With -- Don Guillett SalesAid Software "Arne Hegefors" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I enter formula sum(range+range)*0.15 sumif(range=3) | Excel Discussion (Misc queries) | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Range Question / error 1004: method Range of object Worksheet has failed | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming | |||
how to? set my range= my UDF argument (range vs. value in range) [advanced?] | Excel Programming |