VBA code combining text and data from excel.

marcley467

New Member
Joined
Oct 13, 2015
Messages
7
Hi, I was hoping someone could help me with a VBA code that would combine text and data from excel to a word document. I have unsuccessfully modified & combined code from examples I have found online, and would appreciate any help you can provide. If possible, could you please add comments to the code?

Details:

Excel Document:
Log to Track Non-Conforming product. Each row is a separate entry.
The log consists of multiple columns….(header are: Date, Initiator, Part number, Lot, Qty, Issue, etc.. / Not all data in the row will need to be included within the word document.)

Additional Text:
Additional text is added both before and after the excel data.
  • 2 standard paragraphs (that never change) are above the excel data
  • 3 optional paragraphs, depending upon the disposition of the parts…
    • The 3 optional requirements are: RMA, Credit, and Replacements.
  • 2 additional standard paragraphs below the optional text.

Word Document:
A report is created from the combined info.

If possible, I would like the user to click a command button that would automatically combine the text, data from excel, and optional text.

Formatting/placement of info just aligns to the left margin.
A return would separate the paragraphs/excel data.

I would like the code to:
  • Create new word document
  • Add beginning (2) paragraphs
  • Add excel data: The data exported from excel would be pulled from certain columns in a selected row. The row would be selected by clicking on a predefined cell…
    • For example: the 2nd cell within a row. If the defined cell is not selected, a prompt would ask you to select a row.
  • Add Optional text: The user would receive a y/n prompt for each of the 3 optional requirements. RMA, Credit, and Replacements. For example: Prompt could be a y/n message asking “Do you want to request an “RMA”?. If yes is selected the paragraph requesting an RMA would be added. If no, it would go to the next optional requirement.
  • Add ending paragraph

I am new to this forum and am unsure how to include an example or document but I would be happy to provide any additional info needed. Any help would be greatly appreciated.

Thank you & happy holidays ;)
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Create a Word template with keywords within brackets.

[Date]

[Part number][Lot][Qty][Issue]

etc.

Create a userform to select the record in question along with optionbuttons for the RMA, Credit, and Replacements.

Then, push all the selected info into the Word Document using Word's find and replace. The template will create a new document. And because it's a template, will be ready for the next record.

You'll have to create an account at one of the online file storage companies (I use Box.net) to post sample files to share with us.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top