Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2024, 06:46 AM
l0zzie88 l0zzie88 is offline Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Mac OS X Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Office 2021
Novice
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG
 
Join Date: Jan 2024
Posts: 2
l0zzie88 is on a distinguished road
Red face Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG


Hello,

I'm trying to set up a Macro which will allow a button to be pressed to copy a selection of text from a report and copy it into a summary table.

There will be 3 tables, which are Red, Amber, Green depending on the report issue raised, so the code needs to be able to select the right table, insert the row, and copy to the relevant text into that row.

Is there a way this can be done, I have tried keywords as triggers, but I'm after a simple way to allow the text to be copy and pasted to the corresponding table. I am on a Mac, so making it extra hard in terms of VBA, Macro's and functions in Word!

Thank you
Lauren
Reply With Quote
  #2  
Old 01-18-2024, 06:58 AM
l0zzie88 l0zzie88 is offline Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Mac OS X Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Office 2021
Novice
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG
 
Join Date: Jan 2024
Posts: 2
l0zzie88 is on a distinguished road
Default

I attach a stripped back example here of what I'm trying to achieve.

You can see the 3 summary tables at the top, where the written item is to be added as a new row. The written assessment is below.

In the full report, there are more tables within the document providing different functions, but I'm not sure how to assign a table an ID as a reference to be able to target it with VBA to be able to add the rows, copy the text etc.

Is there a way to highlight the selected text, and have a button to click to copy it to the red, orange or green table accordingly?

Thanks in advance to anyone who can help advise.
Attached Files
File Type: docx example of action tables and write up.docx (16.9 KB, 4 views)
Reply With Quote
  #3  
Old 01-18-2024, 03:42 PM
Guessed's Avatar
Guessed Guessed is offline Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Windows 10 Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If your H/M/L tables are always appearing in that order at the top of the document then your macros might work like this
Code:
Sub MoveIt_High()
  ILikeToMoveIt
End Sub

Sub MoveIt_Medium()
  ILikeToMoveIt 2
End Sub

Sub MoveIt_Low()
  ILikeToMoveIt 3
End Sub

Function ILikeToMoveIt(Optional iTbl As Integer = 1)
  Dim aRng As Range, aTbl As Table, aRow As Row
  Set aRng = Selection.Paragraphs(1).Range
  aRng.End = aRng.End - 1
  Set aTbl = ActiveDocument.Tables(iTbl)
  Set aRow = aTbl.Rows.Add
  aRow.Cells(1).Range.FormattedText = aRng.FormattedText
End Function
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Word macro to insert text at the beginning of paragraph but skip tables ashalles135 Word VBA 5 09-26-2018 09:49 AM
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG word macro To insert text at the beginning and at end of paragraph ArieH Word VBA 20 09-10-2017 04:23 PM
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Creating paragraph macro transform text into table celiolopes Word VBA 2 08-25-2016 04:03 PM
Macro/VBA to copy text paragraph and insert as new row in summary table, with RAG Macro to Insert text into the beginning on specific paragraphs unless the paragraph is blank caboy Word VBA 2 04-01-2015 07:00 AM
Insert table in document - automatically updates second table in summary? Mechanic Word 2 08-01-2012 09:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft