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

[Solved} IF macro help

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Valhalla
Newbie
Newbie


Joined: 05 Jul 2012
Posts: 3

PostPosted: Thu Jul 05, 2012 1:37 am    Post subject: [Solved} IF macro help Reply with quote

Hey everyone!

Im just getting into macros but i am trying to make/get one for a spreadsheet that i am making. The basic purpose would be that of an if function. For instance, with the following numbers represented in A1 and B1 respectively

32 7

i want the macro to say if number in B1 is >6 then subtract 4 from A1 and give the solution back into the A1 cell. I have made a button to assign the macro to so that each time i push it the macro runs. I have several instances that i need to run so just a starting point would help, as i have all but torn out my hair trying to figure something out.

Thanks,
Val


Last edited by Valhalla on Thu Jul 05, 2012 3:07 pm; edited 2 times in total
Back to top
View user's profile Send private message
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Thu Jul 05, 2012 5:47 am    Post subject: Reply with quote

Hi

Code:
Sub Main
Dim Doc As Object, Sheet As Object, CellRange As Object
Doc = ThisComponent
Sheet = Doc.Sheets(0)
Sheet = Doc.Sheets.getByIndex(index)
oSheet = Doc.getSheets().getByIndex(0)
CellB1 = Sheet.getCellRangeByName("B1")
CellA1 = Sheet.getCellRangeByName("A1")
if CellB1.value > 6 then
  CellA1.value = CellA1.value -4
end if
End Sub


remenber, the title of the topic is very important, must reflect the subject matter, please change it
_________________
If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button).
Back to top
View user's profile Send private message
Valhalla
Newbie
Newbie


Joined: 05 Jul 2012
Posts: 3

PostPosted: Thu Jul 05, 2012 3:06 pm    Post subject: Reply with quote

this worked really well hopefully ill be able to play with it and get all the numbers i want i really appreciate it!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API 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