Better way to search thru cells?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
cherkey
Posts: 3
Joined: Fri Mar 14, 2008 11:05 pm

Better way to search thru cells?

Post by cherkey »

Hello,
There has to be a better way to do this...a more efficient way..
I have a number entered from an Inputbox that I'm looking for within a column of cells. Right now I'm just using and if..then - I look at a specific cell and if it's not the number I move to the next cell and so on until I find the number. Is there a way to have the code look at a column range and find the number? Instead of having to add each snippet of elseif for each number possibility..
Thanks IA,
cherkey
cherkey
Posts: 3
Joined: Fri Mar 14, 2008 11:05 pm

Re: Better way to search thru cells?

Post by cherkey »

Oh wait...I just found this...would this work?
cherkey

Sub SearchARange
REM Author: Andrew Pitonyak
Dim oSheet
Dim oRange
Dim oFoundCell
oSheet = ThisComponent.getSheets().getByIndex(0)
oRange = oSheet.getCellRangeByName("F7:H11")
oFoundCell = SimpleSheetSearch("41", oRange, False)
End Sub
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

Re: Better way to search thru cells?

Post by frozbie »

Looks like you answered your own question.

Do you have the function code Andrew wrote? Find it at:

http://www.pitonyak.org/oo.php

Mark
OOo 3.0.X on MS Windows Vista + Windows XP
Post Reply