Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Counter for Calc

Post new topic   Reply to topic Forum Index -> Code Snippets
View previous topic :: View next topic  
Author Message
General User
General User

Joined: 25 Aug 2009
Posts: 26
Location: Järvenpää

PostPosted: Sat Jul 17, 2010 12:14 am    Post subject: Counter for Calc Reply with quote

Here is NimettyLaskuri macro as a counter on the first sheet of a spreadsheet of Calc. With each call of macro with the same argument the value of a cell corresponding that argument is incremented.

If NimettyLaskuri macro is assigned to an event it seems to need intermediate routine like Sub Main here. Or you can just out comment the argument part with brackets and ensure you have that cumbersome default name (NimettyLaskuriP1) for some cell used as the target cell. It is probable that you don't already have a cell with the same name so this avoid some possible mixup.

If target cell has already value, counting is starting from there but possible formula there is destroyed.



Sub Main

 NimettyLaskuri "B3"      'Nimeksi kelpaa myös soluosoite tekstinä

End Sub

Sub NimettyLaskuri (optional sSolunimi as String)
REM tämä rutiini käyttää nimettyä solua, johon listätään joka kusukerralla +1
REM Ensimmäisellä taulukkolehdellä pitää olla NimettyLaskuriP1 niminen solu
REM tai sitten argumentissa pitää olla solun nimi tai viite tekstinä

DIM oLaskuriSolu as Object, oLehti as Object
DIM LTemp as Long
DIM sNimi as String
   sNimi = "NimettyLaskuriP1"      'Oletusnimi laskurille
   IF NOT IsMissing(sSolunimi) AND VarType(sSolunimi)=8 then sNimi = sSolunimi
   oLehti = thisComponent.Sheets.getByIndex(0)
   oLaskuriSolu = oLehti.getCellRangeByName(sNimi)
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Code Snippets All times are GMT - 8 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group