Newbie Here. Help Converting data to multiple columns.

steveblaine

New Member
Joined
Feb 7, 2017
Messages
13
I'm having trouble figuring this out. I need to capture the Name and Company on a separate sheet.

A new record seems to start at the row 'New'.
The 'Name' seems to be always the 5th row below the row 'New'.
The 'Company' seems to be always after the word 'at'.

Here is the raw data.. What is looks like BEFOREHAND.

New
4 hours ago
Send InMail
Ask for review
Update me about Doug Wilbur
Doug Wilbur
CEO, co-founder at Stix
Jordan
New
4 hours ago
Send InMail
Ask for review
Select Charlie JonesidUpdate me about Charlie Jones
Charlie Jones
3rd
Owner at Compuwear
Orange County, California Area
New
4 hours ago
Send InMail
Ask for review
Select Louis RichardsUpdate me about Louis Richards
Louis Richards
3rd
CEO/Founder at Beckman Sounds
Orange County, California Area
New
4 hours ago
Send InMail
Ask for review
Select Emma WonsonUpdate me about Emma Wonson
Emma Wonson
CEO - President at Go Health Solutions, Inc
Greater Philadelphia Area

<tbody>
</tbody>


Here is What I Want it to look like.


NameCompany
Doug WilburStix
Charlie JonesCompuwear
Louis RichardsBeckman Sounds
Emma WonsonGo Health Solutions, Inc

<tbody>
</tbody>

VBA code would be appreciated.
Thank you.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
steveblaine,

Thanks for the Private Message.

Here is a macro solution for you to consider that is based on your two flat text displays, and, that uses two arrays in memory, and, should be fast.

You can change the raw data worksheet name in the macro.

The macro will create a new worksheet, Results.

Sample raw data:


Excel 2007
A
1New
24 hours ago
3Send InMail
4Ask for review
5Update me about Doug Wilbur
6Doug Wilbur
7CEO, co-founder at Stix
8Jordan
9New
104 hours ago
11Send InMail
12Ask for review
13Select Charlie JonesidUpdate me about Charlie Jones
14Charlie Jones
153rd
16Owner at Compuwear
17Orange County, California Area
18New
194 hours ago
20Send InMail
21Ask for review
22Select Louis RichardsUpdate me about Louis Richards
23Louis Richards
243rd
25CEO/Founder at Beckman Sounds
26Orange County, California Area
27New
284 hours ago
29Send InMail
30Ask for review
31Select Emma WonsonUpdate me about Emma Wonson
32Emma Wonson
33CEO - President at Go Health Solutions, Inc
34Greater Philadelphia Area
35
Sheet1


And, after the macro in a new worksheet Results:


Excel 2007
AB
1NameCompany
2Doug WilburStix
3Charlie JonesCompuwear
4Louis RichardsBeckman Sounds
5Emma WonsonGo Health Solutions, Inc
6
Results


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub Extract_Name_Company()
' hiker95, 04/13/2017, ME10000506
Dim w1 As Worksheet, wr As Worksheet
Dim a As Variant, i As Long, ii As Long, n As Long, s, ss As Long
Dim o As Variant, j As Long
Application.ScreenUpdating = False
Set w1 = Sheets("Sheet1")   '<-- you can change the sheet name here
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wr = Worksheets("Results")
wr.UsedRange.Clear
With w1
  a = .Range("A1", .Cells(Rows.Count, "A").End(xlUp))
  n = Application.CountIf(.Columns(1), "New")
  ReDim o(1 To n + 1, 1 To 2)
End With
j = j + 1: o(j, 1) = "Name": o(j, 2) = "Company"
For i = 1 To UBound(a, 1)
  If a(i, 1) = "New" Then
    j = j + 1: o(j, 1) = a(i + 5, 1)
    For ii = i + 5 To i + 10
      If InStr(a(ii, 1), " at ") Then
        s = Split(a(ii, 1), " at ")
        o(j, 2) = s(1)
        i = ii
        Exit For
      End If
    Next ii
  End If
Next i
With wr
  .Cells(1, 1).Resize(UBound(o, 1), UBound(o, 2)) = o
  .Columns(1).Resize(, 2).AutoFit
  .Activate
End With
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm, and, answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Then run the Extract_Name_Company macro.
 
Upvote 0
Thanks Hiker95! That was Genius! The Macro worked as you described and its also fast!
 
Last edited:
Upvote 0
steveblaine,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,226
Members
449,303
Latest member
grantrob

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