+ Reply to Thread
Results 1 to 3 of 3

Autogenerate text based on cell values

  1. #1
    Registered User
    Join Date
    07-11-2022
    Location
    Berlin
    MS-Off Ver
    2021
    Posts
    1

    Question Autogenerate text based on cell values

    Hi all,

    I don't have any expertise with creating macros. Please help me out.
    I would like to create a macros in excel to create a text based on values from other cells.

    For example:
    There is an incident at workplace.
    I enter all details of the incident in column B. Like date, time, location, injury etc. etc. Based on these values/data entered in column in B, I generate a text/report of the incident.

    Please see screenshot of the data entered and the result should generate as:
    On DATE and TIME at LOCATION, employee was working as JOBTITLE. While performing this task XYZ happened. Employee sustained INJURY. First treatment was PROVIDED/DECLINED. Body part injured was BODYPART. Ambulance WAS/NOT REQUIRED. etc.

    Can anyone help me with creating such an excel sheet?

    Thanks.

    Regards,
    Rohan
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Autogenerate text based on cell values

    Use a formula like:

    ="On " &TEXT(B1,"m/d/yyy") & " at " &TEXT(B2,"[hh]:mm") &" at " &B4 & ", employee was working as " &B3 &". While performing this task "&B5 & " happened. Employee sustained " &B9 &". First treatment was "& IF(B11="Yes", "provided.","declined.") & " Body part injured was " &B10 & ". Ambulance was " & IF(B13="no","NOT ") & "required."
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,155

    Re: Autogenerate text based on cell values

    Quote Originally Posted by rohankumar03 View Post
    ... to create a macros in excel to create a text based on values from other cells.
    For example:

    On DATE and TIME at LOCATION, employee was working as JOBTITLE. While performing this task XYZ happened. Employee sustained INJURY. First treatment was PROVIDED/DECLINED. Body part injured was BODYPART. Ambulance WAS/NOT REQUIRED. etc.
    1. Prepare a word document (e.g. Incident Report.doc) as shown in the attached image (or similar you come up with)
    2. Change a bit your current xls file (Incident Description.xlsm) with descriptions in cells as shown in the attached image
    3. 'doc' and 'xlsm' files should be in the same directory on disk
    4. Paste the following code into the macro standard module and save 'Incident Description.xlsm' in xlsm format
    5. Symbolic names ("FDTE", "FTME", "FLOC", etc.) contained:
    a) in the macro code
    and
    b) in the body of the word document
    must be the same and refer to the same description

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by mjr veverka; 07-12-2022 at 04:51 AM.

+ 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. Replacing specific text in multiple text boxes based on cell values
    By ettevi23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2017, 09:21 PM
  2. Autogenerate a sequence of week including cell formatting
    By nlegokloz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2015, 12:35 PM
  3. Replies: 11
    Last Post: 04-30-2015, 05:35 PM
  4. Replies: 3
    Last Post: 12-03-2014, 05:43 PM
  5. Autogenerate Filename from Cell
    By MKWilson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2014, 10:38 AM
  6. AutoGenerate Text
    By SV1974 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-03-2008, 07:56 AM
  7. autogenerate rows based
    By rainxking in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2006, 08:48 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