Ask Your Question
0

having issues with macro skipping a call command

asked 2018-09-24 01:16:13 +0100

ehesh gravatar image

updated 2018-09-25 02:42:29 +0100

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 flag offensive close merge delete

Comments

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?

JohnSUN gravatar imageJohnSUN ( 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

ehesh gravatar imageehesh ( 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)

JohnSUN gravatar imageJohnSUN ( 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

ehesh gravatar imageehesh ( 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

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

1 Answer

Sort by » oldest newest most voted
1

answered 2018-09-26 07:33:39 +0100

JohnSUN gravatar image

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

edit flag offensive delete link more

Comments

Yes thats it thanks

ehesh gravatar imageehesh ( 2018-09-27 23:43:34 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-09-24 01:16:13 +0100

Seen: 45 times

Last updated: Sep 26 '18