[Solved] Merge macro or formula for same contents

Creating a macro - Writing a Script - Using the API

[Solved] Merge macro or formula for same contents

Postby chandrankrishnan » Tue Aug 22, 2017 12:26 pm

Hai all,Good day.

can anyone help me for the attached sheet with formula or macro program for two cells have the same contents means then result has been to be in merged format.

Attached file.

thanks in advance.
Attachments
merge.ods
(11.51 KiB) Downloaded 68 times
Last edited by Hagar Delest on Mon Sep 04, 2017 10:11 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: Merge macro or formula for same contents

Postby hubert lambert » Thu Aug 24, 2017 9:20 am

Hello,

Here's an example:
Code: Select all   Expand viewCollapse view
sub addAndMerge()
    doc = thiscomponent
    sheet = doc.CurrentController.ActiveSheet
    sum = 0
    row = 2   
    first = row
    do
        range = sheet.getCellRangeByPosition(3, row, 7, row+1)
        data = range.DataArray
        sum = sum + data(0)(3)
       
        if data(0)(0) <> data(1)(0) then
            sheet.getCellByPosition(7, first).setValue(sum)
            tobemerged = sheet.getCellRangeByPosition(7, first, 7, row)
            tobemerged.merge(True)
            sum = 0
            first = row + 1
        end if
        row = row +1
    loop until data(1)(0) = ""
end sub

Regards.
Attachments
chandrankrishnan.ods
(14.84 KiB) Downloaded 62 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 125
Joined: Mon Jun 13, 2016 10:50 am

Re: Merge macro or formula for same contents

Postby chandrankrishnan » Thu Aug 24, 2017 10:37 am

Hi hubert lambert ,
Thanks for the program its working fine.you saved my time and i trying this for past one week.

(can you please teach us to make simple macro program like this)

Thanks a ton. Have a Good day.
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: Merge macro or formula for same contents

Postby chandrankrishnan » Thu Aug 24, 2017 11:56 am

Hi
Can you please me to fine tune the program.i.e after sum result the serial number has to be generate as as same as total qty(i.e is in merged condition like 1,2,3 etc)

and then column "K" and "L" to be deleted.

Thanks in advance.
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: Merge macro or formula for same contents

Postby hubert lambert » Thu Aug 24, 2017 12:44 pm

At your service... ;)
Attachments
chandrankrishnan.ods
(14.97 KiB) Downloaded 55 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 125
Joined: Mon Jun 13, 2016 10:50 am

Re: Merge macro or formula for same contents

Postby chandrankrishnan » Sat Aug 26, 2017 7:41 am

Hi
Good day to you.Program work fine,but one thing

after total qty sum(in merged form) i need continuous serial number to be generate(as mentioned in column I(marked in red color) like 1,2,3...

Thanks in advance.
Attachments
chandrankrishnan(2).ods
(14.36 KiB) Downloaded 56 times
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: Merge macro or formula for same contents

Postby chandrankrishnan » Wed Aug 30, 2017 12:31 pm

Hi,
i tried once again with macro program,where its working for continuous serial for 2cell merge,whereas for 3cell merge, continuous serial number is collapsing that is its missing some numbers.

Can any one help me in this regards.

I had attached my entire work sheet with macro program.

Thanks in advance.
Attachments
SFO COMBINE MAC.ods
(24.29 KiB) Downloaded 52 times
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm

Re: Merge macro or formula for same contents

Postby hubert lambert » Wed Aug 30, 2017 2:23 pm

Here it is:
chandrankrishnan.ods
(15.07 KiB) Downloaded 55 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 125
Joined: Mon Jun 13, 2016 10:50 am

Re: Merge macro or formula for same contents

Postby chandrankrishnan » Thu Aug 31, 2017 8:39 am

Hi hubert lambert ,
Thanks a ton.Its working fine and perfect.
Thankyou.
OpenOffice 4.1.2 windows vista
User avatar
chandrankrishnan
 
Posts: 63
Joined: Sat Mar 05, 2016 1:21 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: Zizi64 and 4 guests