Text to Columns

jennformula

New Member
Joined
May 16, 2011
Messages
3
I used some freeware to make a text file of my explorer search results. Text to Columns is not co-operating or i am missing something..the text file is broken down in little blocks. I need to make columns with Name/In Folder/Size/Type/Date Modified all broken down into each column. Text to Columns is not breaking it up at all? See example:



==================================================
Name : Geology Maps- 2004- do not delete
In Folder : M:\Clients\PQR\blank - Restored\padafldkjfalt Feb 2007
Size :
Type : File Folder
Date Modified : 9/22/2009 4:44 PM
==================================================

==================================================
Name : Geology Maps- 2005- do not delete
In Folder : M:\Clients\PQR\Pbkjy Trust - Restored\pkdflkjt Edfd Feb 2007
Size :
Type : File Folder
Date Modified : 9/22/2009 4:45 PM
==================================================
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
jennformula,


Is this what you are starting with (column A), and looking for (columns C thru G)?


Excel Workbook
ABCDEFG
1==================================================NameIn FolderSizeTypeDate Modified
2Name : Geology Maps- 2004- do not deleteGeology Maps- 2004- do not deleteM:\Clients\PQR\blank - Restored\padafldkjfalt Feb 2007File Folder9/22/2009 4:44 PM
3In Folder : M:\Clients\PQR\blank - Restored\padafldkjfalt Feb 2007Geology Maps- 2005- do not deleteM:\Clients\PQR\Pbkjy Trust - Restored\pkdflkjt Edfd Feb 2007File Folder9/22/2009 4:45 PM
4Size :
5Type : File Folder
6Date Modified : 9/22/2009 4:44 PM
7==================================================
8
9==================================================
10Name : Geology Maps- 2005- do not delete
11In Folder : M:\Clients\PQR\Pbkjy Trust - Restored\pkdflkjt Edfd Feb 2007
12Size :
13Type : File Folder
14Date Modified : 9/22/2009 4:45 PM
15==================================================
16
Sheet1





You will generally get much more help (and faster) in this forum if you can post your small samples (what you have and what you expect to achieve) directly in the forum.

To attach screenshots, see below in my Signature block: Post a screen shot with one of these:

If you are not able to give us screenshots, see below in my Signature block: You can upload your workbook to Box Net
 
Upvote 0
jennformula,


Sample raw data in worksheet Sheet1:


Excel Workbook
A
1==================================================
2Name : Geology Maps- 2004- do not delete
3In Folder : M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Aug 2007
4Size :
5Type : File Folder
6Date Modified : 9/17/2009 12:45 PM
7==================================================
8
9==================================================
10Name : Geology Maps- 2005- do not delete
11In Folder : M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Aug 2007
12Size :
13Type : File Folder
14Date Modified : 9/17/2009 12:45 PM
15==================================================
16
17==================================================
18Name : Geology Maps- 2004- do not delete
19In Folder : M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Feb 2007
20Size :
21Type : File Folder
22Date Modified : 9/22/2009 4:44 PM
23==================================================
24
25==================================================
26Name : Geology Maps- 2005- do not delete
27In Folder : M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Trust Feb 2007
28Size :
29Type : File Folder
30Date Modified : 9/22/2009 4:45 PM
31==================================================
32
Sheet1





After the macro in a new worksheet Results:


Excel Workbook
ABCDE
1Path(In Folder)NameSizeTypeDate Mod
2M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Aug 2007Geology Maps- 2004- do not deleteFile Folder9/17/2009 12:45 PM
3M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Aug 2007Geology Maps- 2005- do not deleteFile Folder9/17/2009 12:45 PM
4M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Feb 2007Geology Maps- 2004- do not deleteFile Folder9/22/2009 4:44 PM
5M:\Clients\PQR\XYZ Comp - Restored\XYZ Comp Trust Feb 2007Geology Maps- 2005- do not deleteFile Folder9/22/2009 4:45 PM
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, by highlighting the code and pressing the keys CTRL + C
2. Open your 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 by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub MyExtract()
' hiker95, 05/17/2011
' http://www.mrexcel.com/forum/showthread.php?t=550474
Dim w1 As Worksheet, wR As Worksheet
Dim Area As Range, SR As Long, ER As Long, a As Long, NR As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wR = Worksheets("Results")
wR.UsedRange.Clear
wR.Range("A1:E1") = [{"Path(In Folder)","Name","Size","Type","Date Mod"}]
w1.Activate
For Each Area In Range("A1", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeConstants).Areas
  With Area
    SR = .Row
    ER = SR + .Rows.Count - 1
    NR = wR.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    For a = SR + 1 To ER - 1 Step 1
      If InStr(Cells(a, 1), "Name              :") > 0 Then
        wR.Range("B" & NR).Value = Right(Cells(a, 1), Len(Cells(a, 1)) - 20)
      ElseIf InStr(Cells(a, 1), "In Folder         :") > 0 Then
        wR.Range("A" & NR).Value = Right(Cells(a, 1), Len(Cells(a, 1)) - 20)
      ElseIf InStr(Cells(a, 1), "Size              :") > 0 Then
        If Len(Cells(a, 1)) = 21 Then
          wR.Range("C" & NR).Value = 0
        Else
          wR.Range("C" & NR).Value = Right(Cells(a, 1), Len(Cells(a, 1)) - 20)
        End If
      ElseIf InStr(Cells(a, 1), "Type              :") > 0 Then
        wR.Range("D" & NR).Value = Right(Cells(a, 1), Len(Cells(a, 1)) - 20)
      ElseIf InStr(Cells(a, 1), "Date Modified     :") > 0 Then
        wR.Range("E" & NR).Value = Right(Cells(a, 1), Len(Cells(a, 1)) - 20)
      End If
    Next a
  End With
Next Area
wR.Range("E2:E" & NR).NumberFormat = "m/d/yyyy h:mm AM/PM"
wR.UsedRange.Columns.AutoFit
wR.Activate
Application.ScreenUpdating = True
End Sub


Before you use the macro, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the MyExtract macro.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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