Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 06-17-2021, 05:24 PM
Guessed's Avatar
Guessed Guessed is offline How to sort a list to a table in word Windows 10 How to sort a list to a table in word Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

Approaching this as a coding exercise, there are a steps to break down the problem into bite sized chunks.
1. How do we define the source data range
2. How do we iterate through the source paragraphs to process each one
3. How do we separate the key (team name) from the value (##$ Person)
4. How do we define the table where the data goes and locate the relevant cell in the table
5. How do we add the value in that cell

I'll give you the first couple of steps to get you started.
1. There are numerous ways to achieve this. The simplest is to expect the user to select the source range before running the macro.
2. This is relatively easy because each data set is a paragraph within that range.

Combining both steps 1 and 2 we have this code
Code:
Sub ILike2MoveIt()
  Dim aRng As Range, aPara As Paragraph
  Set aRng = Selection.Range  
  For Each aPara In aRng.Paragraphs
    Debug.Print aPara.Range.Text  'this writes to the Immediate window
  Next aPara
End Sub
The next step is to work out how to separate the team name from the value you want to move. This is kind of complicated because you haven't separated it with anything other than a space and the point at which this begins varies from paragraph to paragraph. So your homework is to work out a clean way to separate the key and value.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
lists, sorting problems



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort Excel table using a list. mthwi Excel Programming 1 05-16-2020 05:57 AM
Can't sort list in report Sharif Project 0 10-21-2019 03:02 AM
How to sort a list to a table in word Sort items in a list into various customers for a report Lluewhyn Excel 5 10-21-2016 05:56 AM
list of documents come up in random order - any ideas how to sort this? tallscot49 Word 0 07-18-2010 12:40 AM
How to sort a list to a table in word Sort By Last Name in a List eliz.bell Word 8 05-07-2009 01:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 PM.


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