Copy specific text from notepad into Excel

  • Thread starter Thread starter Riggi
  • Start date Start date
R

Riggi

Hello all,

Can we copy a number/text from a text file which is in a specific
colomn and row in a text file( 10 spaces long)
and then paste it in the excel sheet. I don't want to use the import
command cuz my text file is not delimited.
There are number randomly placed in the text file which I need to copy
and paste it in the excel cells.

I want to place a button on my spreadsheet which would help the user to

locate the data file and then excel would extract data from that sheet
and paste it in the black spaces on the sheet.

Please Help !!!

Thanks,

Riggi
 
It is easier to open the text file as a vba internal processing file and read
the data rather than using the standard open method.

You can still use the standard dialog to get the file name but then open and
process the file.

The code would be

Sub doit()
Dim fileToOpen As Variant
Dim s As String
fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen = False Then
Exit Sub
End If
Open fileToOpen For Input As #1
Line Input #1, s
Close #1
ans = Mid(s, 20, 10)
End Sub

Modify it to meet your requirments.
 
Thanks, it work!! :)


Martin said:
It is easier to open the text file as a vba internal processing file and read
the data rather than using the standard open method.

You can still use the standard dialog to get the file name but then open and
process the file.

The code would be

Sub doit()
Dim fileToOpen As Variant
Dim s As String
fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen = False Then
Exit Sub
End If
Open fileToOpen For Input As #1
Line Input #1, s
Close #1
ans = Mid(s, 20, 10)
End Sub

Modify it to meet your requirments.
 
Thanks, it worked! :)


Martin said:
It is easier to open the text file as a vba internal processing file and read
the data rather than using the standard open method.

You can still use the standard dialog to get the file name but then open and
process the file.

The code would be

Sub doit()
Dim fileToOpen As Variant
Dim s As String
fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen = False Then
Exit Sub
End If
Open fileToOpen For Input As #1
Line Input #1, s
Close #1
ans = Mid(s, 20, 10)
End Sub

Modify it to meet your requirments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top