Find Cell, Activate Cell

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

Find Cell, Activate Cell

Post by cherkey »

Hello,
Trying to import over an excel spreadsheet with a module but the module needs some tweaking. What do I need to do with this example in order for it to work in Calc?
Thank you,
Cherkey

With Worksheets("sheet1").Columns("A:A")
.Find( _
what:="", _
after:=.Cells(ActiveCell.Row)).Activate
.Cells(ActiveCell.Row) = (partnumber)
End With
User avatar
James
Volunteer
Posts: 264
Joined: Sun Oct 07, 2007 7:23 am
Location: UK

Re: Find Cell, Activate Cell

Post by James »

Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.
Moving to Macros and UNO API
James
www.8daysaweek.co.uk - A User-Focused OOo site.
Windows Easy Installation CDs & OOo on USB Keys, OOo for Mac OS X + Ubuntu CDs

Please read: Survival Guide for the forum
OOo 3.1.1 on Ubuntu 9.x + Windows XPP, Mac OS X
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: Find Cell, Activate Cell

Post by pitonyak »

cherkey wrote:Hello,
Trying to import over an excel spreadsheet with a module but the module needs some tweaking. What do I need to do with this example in order for it to work in Calc?
Thank you,
Cherkey

With Worksheets("sheet1").Columns("A:A")
.Find( _
what:="", _
after:=.Cells(ActiveCell.Row)).Activate
.Cells(ActiveCell.Row) = (partnumber)
End With
This is more difficult in OOo. I do not know what this macro does in VB, so it is difficult to translate, but I can make a few guesses.

Get Sheet1.

Code: Select all

Dim oSheet
oSheet = ThisComponent.getSheets().getByName("sheet1")
Next, you grab the first column, but then it looks like you search through that column.

If you download AndrewMacro.odt, you can see things such as how to obtain the current cell (search for "get the active cell").
It looks like perhaps you are looking for the last used row in column A and setting the value to "part number"

I think if you look at "Which cells are used in a sheet?", you can use that on a column to determine the extent of a column if you desire.

Just a few pointers, but I must be off to bed...
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Find Cell, Activate Cell

Post by Villeroy »

Jump to next cell in column A where this row's value in A is found:
Cell X2 where X is any free column:

Code: Select all

=HYPERLINK("#"&ADDRESS(ROW()+MATCH($A2;$A3:$A$65536;0);1);"Next "&$A2)
copy down and click the hyperlinks.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply