[Solved] Macro with formula returned empty data cells?

Discuss the spreadsheet application
Locked
dennlv
Posts: 7
Joined: Tue Jun 18, 2019 4:54 am

[Solved] Macro with formula returned empty data cells?

Post by dennlv »

Using record macro, i managed to mimic having to repeatedly enter formula in column c to look up column a for same word and then concatenate column b data together if column a has the same word.

However running the macro only return column c empty?

The formula on c2 is something like =if(a2=a1;c1&";"b2;b2). Will upload the .ods and macro when i get the chance later.

Any help would be appreciated. Thxs :D
Attachments
Combine_data_fm_multiple_rows_macro_didnt_work.txt
This is the macro that was recorded that returned column C with empty data instead of the required data as a result from the formula
(1.35 KiB) Downloaded 122 times
Combine_data+fm_multiple_Rows.ods
Will copy the macro in a text file and upload here
(10.44 KiB) Downloaded 116 times
Last edited by dennlv on Tue Sep 03, 2019 12:47 pm, edited 4 times in total.
OpenOffice 4.0 on Windows 10
FJCC
Moderator
Posts: 9281
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: My recorded macro with formula returned empty data cells

Post by FJCC »

If I understand you correctly, you do not need to write a macro. To fill the formula down the column, first enter your formula in C2. Then click on C2 and it will be surrounded by a black border with a small square in the lower right corner. Double click on that square and the formula will be filled down as far as there are data in column B. Alternatively, you can click and hold on that small square and drag down to fill in the formula.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
dennlv
Posts: 7
Joined: Tue Jun 18, 2019 4:54 am

Re: My recorded macro with formula returned empty data cells

Post by dennlv »

No i need a macro to do this as it will be repetitive. Issue with macro not recording the formula which resulted in empty cell when run.
OpenOffice 4.0 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: My recorded macro with formula returned empty data cells

Post by Zizi64 »

Issue with macro not recording the formula which resulted in empty cell when run.
The macro recorder has a limited capability. You must WRITE your macro code - based on the functions and procedures of the API - (instead of recording it), is you want work efficiently with the macros.

API = Application Programming Interface. You can use the API functions from all of available and supported programming languages.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
dennlv
Posts: 7
Joined: Tue Jun 18, 2019 4:54 am

Re: My recorded macro with formula returned empty data cells

Post by dennlv »

Thxs Zizi64, i have tried looking at the codes but i might not have the capability as someone without programming knowledge. Would you be able to help point how i can insert the formula into the macro i shared for me to try start somewhere?
OpenOffice 4.0 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: My recorded macro with formula returned empty data cells

Post by Villeroy »

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
dennlv
Posts: 7
Joined: Tue Jun 18, 2019 4:54 am

Re: My recorded macro with formula returned empty data cells

Post by dennlv »

Thanks.
I seems to progress by inserting the string of formula myself but there is the next issue of inserting the formula [=IF(I2<>I3;"last";"")] without [] as "quotes" is a allowed in building macro. Any tips to cross this next hurdle?
OpenOffice 4.0 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: My recorded macro with formula returned empty data cells

Post by Zizi64 »

All of the cells can store a numeric value AND a string AND a formula in same time.

When you put a formula into a cell (manually or by a macro) it will be calculated, and the result will be a numeric value or a string. When the result is a numeric value, the string - stored by the cell - will be the formatted textual view of the numeric result.
You can modify all of the types of the cell content (string, value, formula) by the API functions.

viewtopic.php?f=20&t=92611
https://wiki.openoffice.org/wiki/HU/Doc ... and_Ranges
https://ask.libreoffice.org/en/question ... cro-basic/
https://ask.libreoffice.org/en/question ... a-formula/
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
MrProgrammer
Moderator
Posts: 4909
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: My recorded macro with formula returned empty data cells

Post by MrProgrammer »

dennlv wrote:i managed to mimic having to repeatedly enter formula in column C …
dennlv wrote:No i need a macro to do this as it will be repetitive.
There may be better ways to accomplish this task than with an evil macro. You should explain your ultimate goal, not the step you have decided upon. Why do you need to populate column C repeatedly? Do you need to populate other columns too? Are you doing this in multiple sheets? Or in multiple files?
The XY Problem
"The problem occurs when people get stuck on what they believe is the solution and are unable step back and explain the issue in full."
dennlv wrote:Issue with macro not recording the formula which resulted in empty cell when run.
This is known issue 111471: Calc, record macro, cells with function written manually not recorded
Use Insert → Function instead of typing the formula directly into the cell. Personally I think it's easier to replicate the formula with Edit → Fill → Down instead of Copy/Paste. I have added the "Issue" icon to your post.
Zizi64 wrote:The macro recorder has a limited capability.
Yes, however entering something in a cell and filling it down is very simple with the user interface and a task that the macro recorder should handle. It doesn't due to the issue above. The issue can be circumvented with Insert → Function or by omitting the initial equal sign in the formula then performing a simple edit on the recording. This is much easier than spending a couple of weeks to learn how to write macros using the UNO application programming interface.
dennlv wrote:I seems to progress by inserting the string of formula myself but there is the next issue of inserting the formula [=IF(I2<>I3;"last";"")] without [] as "quotes" is a allowed in building macro. Any tips to cross this next hurdle?
I don't understand this post. Did you enter the [] to circumvent the issue above? If not, why did you use [] since this is not valid formula syntax? If so, use Tools → Macros → Organize macros → OpenOffice Basic → Edit, then remove the [] and save the edited macro.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
dennlv
Posts: 7
Joined: Tue Jun 18, 2019 4:54 am

Re: [Solved].. macro with formula returned empty data cells?

Post by dennlv »

Wow Mrprogramer, your insert crtl+F2 during recording did it for me. Sorry about not being clear as most of my time, i was typing away using hp. Yes, i can now use this macro on files with the same formatted worksheet! Looks like macro here is better than excel! And the prompt and quality replies here is where one dare to invest time in!

Well done guys and Thank you very much!
OpenOffice 4.0 on Windows 10
Locked