500 Characters to 500 Cells

MurfGBRX

New Member
Joined
Mar 15, 2019
Messages
1
[FONT=&quot]I have a txt file that is exactly 500 characters wide and can have several thousand ‘rows’ of data that are also exactly 500 characters wide. Frequently I am required to scroll through such files and find issues with the data. That is very time consuming and modifying a file like this is difficult, tedious, and frequently leads to more data issues. [/FONT]
[FONT=&quot]Horrifying I know. [/FONT]
[FONT=&quot]What I would like is a reasonably easy way to convert each individual character to a cell so that the file is easier to understand and edit. [/FONT]
[FONT=&quot]I know there is a way to convert text to columns with custom column widths, but clicking through each file ~ 500 times is time consuming and is also prone to human error.

I would appreciate any help. [/FONT]
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I think this macro will do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub FiveHundredCharsToFiveHundredCells()
  Dim X As Long, FileNum As Long, TotalFile As String, Chars As Variant, Lines() As String
  FileNum = FreeFile
  Open "[B][COLOR="#FF0000"]C:\Temp\500Chars.txt[/COLOR][/B]" For Binary As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] 
    TotalFile = Space(LOF(FileNum))
    Get [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] , , TotalFile
  Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum]#FileNum[/URL] 
  Lines = Split(TotalFile, vbCrLf)
  Application.ScreenUpdating = False
  For X = 0 To UBound(Lines)
    With Cells(X + 1, "A").Resize(, 500)
      .NumberFormat = "@"
      .Value = Split(StrConv(Lines(X), vbUnicode), Chr(0))
    End With
  Next
  Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
Change the red colored filename/path to your actual file's location.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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