Create an macro to search specific data

Oh, I looked at your picture!

Unfortunately, we have a typical “XY problem” here - you asked for a macro from the very beginning and we tried to make a macro for you.

In fact, you need specific values ​​from table A14:D41, which are easy to obtain using not very complex formulas and writing a macro is the way you came up with because you didn’t know how to make these formulas.

Let’s put the search texts you labeled “text to find 1”, “some text to find 2”, etc., in cells H7:Q7. If you don’t want to see them there, that’s not a problem, there are many ways to hide them (white font on white background, cell format code ;;; and a few others).

Now in cell H8 write =IFERROR(VLOOKUP(H$7;$A$14:$D$41;4;0);NA())

And in cell H10 write =IFERROR(VLOOKUP(H$7;$A$14:$D$41;3;0);NA())

These formulas differ in only one digit (4 or 3) - the column number in table A14:D41

Now format these two cells the way you want (as Currency justify right).

Copy this, highlight the I8:Q10 range and paste.

I assure you - it is much easier and faster than writing a macro, debugging it and making it work correctly.

Hmmmm you misunderstand me!

To clarify:

in column A14:A41 I have text 27 different texts. I am interested for 11.

in column D14:D41 I have values

in column E14:E41 I have another values

If I found in A15 “text 1” then copy value from D15 to H8 and copy value from E15 to H10

if I found in A17 “text 2” then copy value from D17 to I8 and copy value from E17 to I10

Every day I get file where are strings in column A, but not every time in same row. That is the problem.

I need to find 11 string and copy total of 22 values.

So copy values from column D to row 8 and values from column E to row 10 from column H to Q

=INDEX($E$14:$E$41;MATCH("SomeText 1";$A$14:$A$41;0)) find text ind write value in cell.

I need that values in H8:Q10 because I copy this to another document.

I hope that this is understandable.

Hmmmm you misunderstand me!

To clarify:

in column A14:A41 I have text 27 different texts. I am interested for 11.

in column D14:D41 I have values

in column E14:E41 I have another values

If I found in A15 “text 1” then copy value from D15 to H8 and copy value from E15 to H10

if I found in A17 “text 2” then copy value from D17 to I8 and copy value from E17 to I10

Every day I get file where are strings in column A, but not every time in same row. That is the problem.

I need to find 11 string and copy total of 22 values.

So copy values from column D to row 8 and values from column E to row 10 from column H to Q

=INDEX($E$14:$E$41;MATCH("SomeText 1";$A$14:$A$41;0)) find text and write value in cell.

I need that values in H8:Q10 because I copy this to another document.

I hope that this is understandable.

You don’t believe me. You have the right to doubt. But try it anyway. Here is a sample file.
Search specific data.ods

How It Work.png

Pretty much correct.
Let me know how to attach image and how file.ods

Oh, it’s very easy. Go back to your question, under it there is the word “edit” - click on it.

AddFileOrImage.png

Thank you!
I edited my question and rewrite basic code. Also add sample and image.
To put formula in cell is not a problem. I would like that macro does this for me. Not put formula to cell. Just read value from one cell and write value to another!
It need to written in LO basic language!

Why can not add image/file to comment?

P.S. How to add CR in comment (chr$10+chr$13)?