+ Reply to Thread
Results 1 to 13 of 13

[SOLVED] macro for Text Generator based of fields

Hybrid View

adamheon [SOLVED] macro for Text... 08-29-2013, 11:08 AM
patel45 Re: macro for Text Generator... 08-29-2013, 11:31 AM
adamheon Re: macro for Text Generator... 08-29-2013, 11:52 AM
patel45 Re: macro for Text Generator... 08-30-2013, 02:47 AM
adamheon Re: macro for Text Generator... 08-30-2013, 08:37 AM
patel45 Re: macro for Text Generator... 08-30-2013, 12:32 PM
adamheon Re: macro for Text Generator... 08-30-2013, 08:18 AM
adamheon Re: macro for Text Generator... 08-30-2013, 01:27 PM
patel45 Re: macro for Text Generator... 08-30-2013, 02:46 PM
adamheon Re: macro for Text Generator... 09-03-2013, 08:17 AM
adamheon [SOLVED] macro for Text... 09-03-2013, 09:58 AM
patel45 Re: macro for Text Generator... 09-03-2013, 12:01 PM
adamheon Re: [SOLVED] macro for Text... 09-03-2013, 12:12 PM
  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    [SOLVED] macro for Text Generator based of fields

    I am trying to create a macro to apply to a button that will automatically generate 1 line of text from multiple lines.

    so to try and better explain this, i will have several options that need to be either selected from a drop down or entered as text (or #). Then i want to combine all that information and have it become 1 line of text.

    example:

    question 1 - xyz
    question 2 - abc
    question 3 - 123

    click generate button

    specific cell = xyz, abc - 123

    attached is the actual information and additional notes in red that i would like to see. hopefully this helps. any help would be much appreciated!! EXAMPLE.xlsxEXAMPLE.xlsx
    Last edited by adamheon; 09-03-2013 at 12:12 PM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: macro for Text Generator based of fields

    you don't need vba or button, put in B5 this formula
    = "(PAR) " & G5 & " " & G6 & " " & G7 & " - (" & G8 & ")" & G9 & "+(" & G10 & ")" & G11 & "+(" & G12 & ")" & G13 &"  X " &G14
    in C5
    ="MARK:" & G4
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: macro for Text Generator based of fields

    im looking for the button becuase i want to be able to generate multiple "orders" or lines from the same information area. So basically i would like to enter the info needed, click the button, have it clear the information entered and generate a single line of text. Then i can repeat the process and click the button and it will add a new line under the previous one. Does that make sense?

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: macro for Text Generator based of fields

    Sub a()
    LR = Cells(Rows.Count, "B").End(xlUp).Row + 1
    Range("B" & LR) = "(PAR) " & Range("G5") & " " & Range("G6") & _
    " " & Range("G7") & " - (" & Range("G8") & ")" & Range("G9") & _
    "+(" & Range("G10") & ")" & Range("G11") & "+(" & Range("G12") & _
    ")" & Range("G13") & "  X " & Range("G14")
    Range("C" & LR) = "MARK:" & Range("G4")
    End Sub

  5. #5
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: macro for Text Generator based of fields

    As i'm putting this into my actual sheet i came up with one error.

    i need the generated text to start at cell D4839 and then continue from there. below are the changes i made, the first line has the error.

    Sub GENERATE()
    LR = Cells(Rows.Count, "D4839").End(xlUp).Row + 1
    Range("D4839" & LR) = "(PAR) " & Range("Q4842") & " " & Range("Q4843") & _
    " " & Range("Q4844") & " - (" & Range("Q4845") & ")" & Range("Q4846") & _
    "+(" & Range("Q4847") & ")" & Range("Q4848") & "+(" & Range("Q4849") & _
    ")" & Range("Q4850") & "  X " & Range("Q4851")
    Range("F4839" & LR) = "MARK:" & Range("Q4841")
    End Sub

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: macro for Text Generator based of fields

    Sub GENERATE()
    LR = Cells(Rows.Count, "D").End(xlUp).Row + 1
    Range("D" & LR) = "(PAR) " & Range("Q4842") & " " & Range("Q4843") & _
    " " & Range("Q4844") & " - (" & Range("Q4845") & ")" & Range("Q4846") & _
    "+(" & Range("Q4847") & ")" & Range("Q4848") & "+(" & Range("Q4849") & _
    ")" & Range("Q4850") & "  X " & Range("Q4851")
    Range("F" & LR) = "MARK:" & Range("Q4841")
    End Sub
    cell D4838 must be not empty
    Last edited by patel45; 08-30-2013 at 12:37 PM.

  7. #7
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: macro for Text Generator based of fields

    That worked perfect! Thank you! The only other thing I was hoping the button would do is also clear the data in cells G4-G14 when clicked.

  8. #8
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: macro for Text Generator based of fields

    the problem there are other areas in column D that have text. So this wants insert the text down at the bottom of the spreadsheet. Is there a way to have it insert in a specific cell? (D4839)

  9. #9
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: macro for Text Generator based of fields

    yes, but need a service cell (for example X1) for saving the last row number, only the first time you need D4839
    Sub GENERATE()
    LR = Range("X1") ' put 4839
    Range("D" & LR) = "(PAR) " & Range("Q4842") & " " & Range("Q4843") & _
    " " & Range("Q4844") & " - (" & Range("Q4845") & ")" & Range("Q4846") & _
    "+(" & Range("Q4847") & ")" & Range("Q4848") & "+(" & Range("Q4849") & _
    ")" & Range("Q4850") & "  X " & Range("Q4851")
    Range("F" & LR) = "MARK:" & Range("Q4841")
    Range("X1").value = Range("X1").value +1
    End Sub
    Last edited by patel45; 08-30-2013 at 02:50 PM.

  10. #10
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: macro for Text Generator based of fields

    Sorry i'm not great at vba. So with the code you posted, you're saying that i need a service cell (example x1). Not sure what a service cell is, but in the attached example i have multiple lines of text (labeled ORDER and test) in column B. however i need to new text to generate under the word ORDER not under the last row of text. I'm sure you have answered this but i'm unclear as to how to modify the code. If you could provide a sample code for this example i think i could figure it out. thanks for your help!

    EXAMPLE.xlsm

  11. #11
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    [SOLVED] macro for Text Generator based of fields

    never mind i was able to figure out what you were saying. Everything works perfectly! Thank you for your help!

  12. #12
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: macro for Text Generator based of fields

    great ! but you have to put [SOLVED] in the title of the first post, not in the current

  13. #13
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: [SOLVED] macro for Text Generator based of fields

    all set put in under the first post. thanks again.

+ 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. Macro/VBA help. Copy and pasting fields based off of a combination of cell values.
    By devin1428 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-12-2012, 06:00 PM
  2. Create a chart based on Text fields using Data Validation
    By mitchyfel in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-04-2010, 09:01 AM
  3. Percentages off 2 text based fields
    By reynastus in forum Excel General
    Replies: 1
    Last Post: 04-30-2010, 03:57 AM
  4. [SOLVED] Calculated Fields Based on Running Total Fields?
    By Kruncher in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2006, 01:25 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