ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get certain words from a line into a cell (https://www.excelbanter.com/excel-programming/409535-get-certain-words-line-into-cell.html)

Mark[_66_]

Get certain words from a line into a cell
 
Hello

Just hoping someone can send me in the right direction here with a
method that might work here. I am extracting data from text files
based on finding a certain word. If found, the whole line in the text
doc will be pasted into a row in excel. There are certain things in
these rows like just the web address, or page title, that I want in
the Excel doc rather than the entire line. Would this be parsing
usign tokens or something? Any help or pointers would be great!
Thanks a lot

Mark

JaimeVasquez

Get certain words from a line into a cell
 
On Apr 17, 9:48 am, Mark wrote:
Hello

Just hoping someone can send me in the right direction here with a
method that might work here. I am extracting data from text files
based on finding a certain word. If found, the whole line in the text
doc will be pasted into a row in excel. There are certain things in
these rows like just the web address, or page title, that I want in
the Excel doc rather than the entire line. Would this be parsing
usign tokens or something? Any help or pointers would be great!
Thanks a lot

Mark


Try with something like this:

Sub GetTitle()
Dim sLine As String, iStart As Integer, iEnd As Integer, cTitle As
String

sLine = "<head id=ctl00_ctl00_Head1<base href=http://
www.sqlteam.com/default.aspx /<meta http-equiv=Content-Type
content=text/html; charset=utf-8 /<link rel=SHORTCUT ICON href=http://
www.sqlteam.com/favicon.ico /<link rel=alternate type=application/rss
+xml title=SQLTeam.com -- SQL Server Information href=http://
feeds.sqlteam.com/sqlteam /<titleGenerating ADO Parameters with
Information Schema Views - SQLTeam.com</title<link rel=stylesheet
href=sqlteam2.css type=text/css /<link rel=stylesheet href=csharp.css
type=text/css /"

iStart = InStr(1, sLine, "<title", vbBinaryCompare) +
Len("<Title")
iEnd = InStr(1, sLine, "</title", vbBinaryCompare)

cTitle = Mid(sLine, iStart, iEnd - iStart)
MsgBox cTitle, , "Title"

End Sub

This extracts the page title, something similar can be done to extract
the url.

notice that the line used is not a valid html text, all double quotes
have been removed to show the example.

source of example: http://www.sqlteam.com/article/gener...n-schema-views


HTH

Jaime Vasquez

Rick Rothstein \(MVP - VB\)[_1744_]

Get certain words from a line into a cell
 
It is kind of hard to give you code without more information. Can you show
us a (real) sample of text from the text file and the words you would be
looking for and the parts you want extracted?

Rick


"Mark" wrote in message
...
Hello

Just hoping someone can send me in the right direction here with a
method that might work here. I am extracting data from text files
based on finding a certain word. If found, the whole line in the text
doc will be pasted into a row in excel. There are certain things in
these rows like just the web address, or page title, that I want in
the Excel doc rather than the entire line. Would this be parsing
usign tokens or something? Any help or pointers would be great!
Thanks a lot

Mark




All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com