Calc, Copy a certain value from one sheet to another

AWESOME!!! Thank you, thank you, thank you!!
its working :smiley:

Ok, I’m trying to understand the code and have somewhat of an idea of how it is working.
I would like to add a few more buttons performing similar functions.

P.S. i hate these comments character limits

Basically, I want to have my whole collection on the main sheet (as it is now) then a button outputting what i have for trade (as the above code does) but I need the sheet name to be Awakenings for trade.

Am I correct in changing line 14 & 15 “For_Trade” to “Awakenings_For_Trade” ? and then updating any lines related to that tag?

I need the button only to check from A3:K176 (im not sure where the top code is reading from and to) how does it know to check the value in column K?? is that in line 17?
Also I need it to start pasting from row A3 in the new page (so I can add the awakenings header to the “for trade sheet”

Once that is all done, I would like another button (or could even use the same button, just thought another button would make coding a little easier) that would check the “count” column (the A column) and if it has a value of 0, output to a new sheet called “Awakenings_Need”

Once that is all done, I will need to add another 2 buttons performing a very similar function to the previous 2, but outputs to 2 new sheets.
these new buttons would now check from A178:K(wherever the next set ends) and do the same function as the above but outputting to a new sheet called “SOR_For_Trade” or “Spirit_For_Trade” and then the other button for performing the “SOR_Need” function.

Maybe we could discuss this over a PM or email?
not sure how or where to do that on this site though…

You’re welcome @Snake3y3s:),

i updated the macro in my answer. changed the sheet name “For_Trade” into “Awakenings_For_Trade”, and start pasting from cell A3.

The check for column K happens in the line If oRow.getCellByPosition( 10, 0 ).getValue() > 0 Then. ( column index 10 = K)

i also added a method SWD_AwakeningsNeed() for the “Needed Cards”.
The Spirit sheets could be easily copied and adapted from these 2.

Just leave at least 1 row empty between the SWD and Spirit area.

Wow… this is awesome, thank you very much… I really appreciate the help.
you asked “For the “Needed Cards”: (should the row for Luke Skywalker really be excluded ??)”
im not following where that would be excluded…

Well, since you wanted to check only from A3:K176, and the row with Luke Skywalker is row 2 in the example file that you uploaded before.

oh, that was just as an example file.
in row 2 I added a header I merged cells A to K and added “Awakenings”
going to do the same for the next set, but add a header called “Spirit of the Rebelion”

what is the purpose of the value 1023 in “clearContents( 1023 )”

1023 stands for all possible content types to delete, it is the sum of 512+256+128+64+32+16+8+4+2+1 , constants of type com.sun.star.sheet.CellFlags

@librebel found one error.
for the “needed” macro, after I added the “spirit of rebellion” set underneath the Awakenings set, skipping one row, it seems to copy all the rows with a Column A value of 0 to the new sheet, not only from A3:K176. (the awakenings set)
Also, instead of using the 0 value from the first row to check if its complete… could we rather make it check the “Complete” column if it has a NO. (Column J)

of course… the second set has another starting row.

i suggest you make a separate question for it, since this question is solved already,

Please mark the above answer as correct by clicking on the :heavy_check_mark: icon on the upperleft side of the answer.

i have updated the 2 earlier macros for the Awakenings cards,
Hope these all work OK now,

i also added the 2 new macros for the second set of cards here, since they are so similar.

Cheers, lib

Thank you so much for your time and help.
It seems to work perfectly :smiley:
still need to add the Spirit set, which I am busy with, then I will add those buttons in.
in the code, what does “oCursor.collapseToSize ( 10, 176 )” do?
… does it take the initial cursor setting , in this case column A row 2 “(0, 2)” and selects all the way down to column K row 176?

Great to read it works.

The nomenclatura of the XSheetCellCursor methods can be confusing sometimes…

.collapseToSize( nColumns, nRows ) changes the size of the cursor range so that it has nColumns columns and nRows rows.

For the spirit code…
Does the line “oCursor.gotoOffset( 0, 179 )” indicate where to start doing the lookup?

yes, it moves the xCellCursor to the starting point of the Spirit rows to be copied. The passed Column and Row offsets are relative to the current cursor position.

I have gotten most of the functionality working now… except the copy to other sheets.

so I would like to get that working. Can anyone assist me?

destiny test.ods

In the attached File you can see what i have so far…
it reads count vs max and outputs a yes or no if complete, then tells me how many I have extra for trade.

I want to now do a check on if it is complete and I have trades (so if row J shows “yes” AND the For Trade number equal to or higher than 1 in row K)

I want it to then take that row and put it in a new sheet.

Please edit your question, don’t use answers for that.