+ Reply to Thread
Results 1 to 4 of 4

standard output message

  1. #1
    Registered User
    Join Date
    09-19-2022
    Location
    Delft
    MS-Off Ver
    office 365
    Posts
    12

    standard output message

    Hello,

    I want to make a macro that makes a standard output message with some variables when I press a button. I put an excel sheet in the attachments to explain what I mean. I want the macro to copy the message so it is on my clipboard and I can paste it in an other application.

    I want to make a macro where I can make this message:
    "
    Hello, we have a new job:
    [JOB(col.B)]
    🗓 [DATE(col.A)] starts [begin(col.D)] until [end(col.E)]

    🦐 There are [counted people(col.G:colI)]/[people needed(col.F)] slots available.

    Let us know if you want to work!
    "

    So for example, the message for row 6 should look like this:
    "
    Hello, we have a new job:
    Ticketscan 2 Peacock
    🗓 04-03 starts 12:30 until 20:00

    🦐 There are 1/2 slots available.

    Let us know if you want to work!
    "


    What is the easiest way to realise this? I have some experience in VBA but that is mostly recording macro and editing it or copying it from a youtube video.

    P.S. I don't know if it makes any difference but I use mac.

    Every bit of help is much appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,657

    Re: standard output message

    I'd suggest not to use button, but double click in any cells in range G:I
    For example, double click on G6 (or H6 or I6), a text string will be generated in cell, i.e, K6, then copy.
    Move to other application then paste.
    This code is put in worksheet module: (Right click tab' name, viewcode then copy/paste)
    PHP Code: 
    Option Explicit
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As RangeCancel As Boolean)
    Dim lr&, r&, avail&, msg As String
    Cancel 
    True
    lr 
    Cells(Rows.Count"A").End(xlUp).Row
    If Intersect(TargetRange("G2:I" lr)) Is Nothing Or Target.Count 1 Then Exit Sub
    Target.Row
    avail 
    Cells(r"F") - WorksheetFunction.CountA(Range(Cells(r"G"), Cells(r"I")))
    Select Case avail
        
    Case 0
              MsgBox 
    "Full!"
              
    Exit Sub
        
    Case Else
            
    msg "Hello, we have a new job:" vbLf Cells(r"B") & vbLf Format(Cells(r"A"), "dd-mm") & _
            
    " starts " Format(Cells(r"D"), "hh:mm") & " until " Format(Cells(r"E"), "hh:mm") & vbLf vbLf _
            
    "There are " avail "/" Cells(r"F") & " slots available."
    End Select
    Cells
    (r"K").Value msg ' use column K to generate message. Adjust to any other column if K is not available.
    Cells(r, "K").Copy
    End Sub 
    Attached Files Attached Files
    Quang PT

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: standard output message

    here is formula solution. It wil be real time. If you edit any row (adding name in column G:I) automatically message will be up dated. No need of running macro.
    In K2 copied down.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Registered User
    Join Date
    09-19-2022
    Location
    Delft
    MS-Off Ver
    office 365
    Posts
    12

    Re: standard output message

    Thank you both very much. I used the macro from the first reaction and added the Putinclipboard function of vba. So it is easy to use for everyone.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] No Error Message produced, but no output either
    By Matthew55 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-18-2018, 04:06 PM
  2. [SOLVED] Not getting correct output in message
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-09-2015, 09:28 PM
  3. macro which sends email to few receipients with a standard message
    By megtoma in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-21-2014, 07:57 AM
  4. Commas, Decimals and Standard Number with nothing -- Output separated data
    By dmcbrier in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-23-2013, 02:21 PM
  5. Message Output
    By oliver79 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-15-2008, 10:26 AM
  6. [SOLVED] Intercept/replace standard 'cell protected' message with my own message?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2006, 10:35 AM
  7. Unprotect Sheet - Removal of standard Message
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-31-2005, 10:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1