# having issues with macro skipping a call command

A few days ago someone helped me with a macro which I incorporated into my work. I assigned the macro to a button and added a few more lines of code and am having issues running the macro. It just skips a command.

There are three sections. The "list" (A11:A13) which is concatenated into a single field (B2). The macro does the following:

1. Takes the range A2:D2 and copies it to the next sheet.
2. Copy cell B2
3. Delete the list section A11:A13

The macro is following numbers 1 and 3, but it does not follow the copy cell code

I included the document below. Thanks in advance

C:\fakepath\TESTEXAMPLE.ods

edit retag close merge delete

The macro performs all the prescribed actions. In any case, after the completion of the macro, the contents of cell B2 remain on the clipboard. Or did you want to copy this not to the clipboard, but to some cell on the sheet?

( 2018-09-24 10:02:29 +0100 )edit

oh yeah, I missed a part of the question, I edited the question to correct it. If I run the macro itself everything works. But I have the macro linked to a button. When I press the button the copy part does not work. That is the problem

( 2018-09-25 02:45:04 +0100 )edit

No, it's still not clear. If the macro copies the range of A2:D2, then it also copies the B2 cell too, because it's in this range. Delete everything that you added to the GetFirstEmptyRow() function (or just go back to the macro from the previous answer) and add only one single line before the End Sub line - oSheets.getCellRangesByName("Sheet1.A11:A13")(0).clearContents(7)

( 2018-09-25 07:05:54 +0100 )edit

It does copy as part of the cell range. but after copying the cell range over I want to copy B2 so I can just go to another cell or document and paste the content. You may see that on row 74 of the macro code after copying the range there is a command entered to copy B4. If I go to the Tools menu and then run the Macro from there it works. But if I try to run it from the button it skips the code from line 72-80

( 2018-09-25 22:42:14 +0100 )edit

In your question, there was not enough of these words - "so I can just go to another cell ... and paste the content.". Now your problem has become clear.

You want to get the result of calculations to the clipboard, not the formula =CONCATENATE(...). So, it's better to copy not cell B2, but the corresponding cell from Sheet2

( 2018-09-26 07:23:46 +0100 )edit

Sort by » oldest newest most voted

It seems to me that this is what you were trying to achieve - C:\fakepath\ResToClpbrd.ods

more