Posts by royUK

    Try this, I haven't tested it


    Have you read the Forum Rules and understand about "Hijacking"? I am deleteing your post in the other person's Thread.

    Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.

    Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!


    Read this to understand why we ask you to do this


    Attach an example workbook

    Make sure that the macro to run is declared as Public


    For the button workbook add a macro to call the other macro and assign that to the button


    Code
    1. Sub RunMacro{}
    2. Application.Run "ConsolidateDischargeRequests.xlsm!NameOfMacroHere"
    3. End Sub

    This will work on addins, but for a workbook I should think that both workbooks need to be open

    Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.


    Why are you trying to dd a button to run code from another workbook?

    Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.


    You might want to provide your solution which might help others or maybe you will get better code offered.

    Your code is not improved or faster by the way you write it using : instead of separating lins. All that does is make it harder to under stand what you are doing.


    The code doesn't seem to do much so it should be fairly fast.


    Instead of

    Code
    1. Lr1 = ws1.Range("A" & ws1.Rows.Count & "").End(xlUp).Row


    Then changing the value later without using it first


    Code
    1. Let Lenf1 = Lr1 - 1

    Why not simply


    Code
    1. Lr1 = ws1.Range("A" & ws1.Rows.Count & "").End(xlUp).Row-1


    I can't see why you use Let either

    You don't set a Range for Target in Event Code. Target refers to the selection in such code.


    Try the calculate event


    Code
    1. Private Sub Worksheet_Calculate()
    2. If Me.Range("E1").Value > 2 Then MsgBox "MI 14.10.2020 / 0900-1000 bereits ausgebucht! Bitte wählen Sie ein anderes Datum!"
    3. If Me.Range("E2").Value > 2 Then MsgBox "FR 16.10.2020 / 1100-1200 bereits ausgebucht! Bitte wählen Sie ein anderes Datum!"
    4. If Me.Range("E3").Value > 2 Then MsgBox "DI 20.10.2020 / 1600-1700 bereits ausgebucht! Bitte wählen Sie ein anderes Datum!"
    5. If Me.Range("E4").Value > 2 Then MsgBox "DO 22.10.2020 / 1330-1430 bereits ausgebucht! Bitte wählen Sie ein anderes Datum!"
    6. End Sub

    Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.