Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default need help opening text file

What I need is to open a text file, search through column A for a specific
number lets say "9135". this number will appear twice in column A so I want
to copy everything between the instance of 9135 and paste in a worksheet in
the next available empty row. I am not a programmer and I am completely lost
any help would be appreciated!

Armadeus


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default need help opening text file

Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(9135)
if not rng is nothing then
set rng1 = columns(1).find(9135,rng)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy

"armadeus" wrote in message
...
What I need is to open a text file, search through column A for a specific
number lets say "9135". this number will appear twice in column A so I

want
to copy everything between the instance of 9135 and paste in a worksheet

in
the next available empty row. I am not a programmer and I am completely

lost
any help would be appreciated!

Armadeus




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default need help opening text file

Keeps giving the error 'First Instance not found' on a popup and doesn't
paste into worksheet.
"Tom Ogilvy" wrote in message
...
Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(9135)
if not rng is nothing then
set rng1 = columns(1).find(9135,rng)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy

"armadeus" wrote in message
...
What I need is to open a text file, search through column A for a

specific
number lets say "9135". this number will appear twice in column A so I

want
to copy everything between the instance of 9135 and paste in a worksheet

in
the next available empty row. I am not a programmer and I am completely

lost
any help would be appreciated!

Armadeus






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default need help opening text file

It is looking for the number 9135 in a cell by itself. If it is a string,
then it won't find it or if it is part of a string. Here is the adjustment
if that is the case:

Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(What:="9135", _
Lookin:=xlValues, LookAt:=xlPart)
if not rng is nothing then
set rng1 = columns(1).find(What:="9135",After:=rng, _
Lookin:=xlValues, LookAt:=xlPart)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy


"armadeus" wrote in message
...
Keeps giving the error 'First Instance not found' on a popup and doesn't
paste into worksheet.
"Tom Ogilvy" wrote in message
...
Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(9135)
if not rng is nothing then
set rng1 = columns(1).find(9135,rng)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy

"armadeus" wrote in message
...
What I need is to open a text file, search through column A for a

specific
number lets say "9135". this number will appear twice in column A so I

want
to copy everything between the instance of 9135 and paste in a

worksheet
in
the next available empty row. I am not a programmer and I am

completely
lost
any help would be appreciated!

Armadeus








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default need help opening text file

Thanks Tom that did it!
"Tom Ogilvy" wrote in message
...
It is looking for the number 9135 in a cell by itself. If it is a string,
then it won't find it or if it is part of a string. Here is the

adjustment
if that is the case:

Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(What:="9135", _
Lookin:=xlValues, LookAt:=xlPart)
if not rng is nothing then
set rng1 = columns(1).find(What:="9135",After:=rng, _
Lookin:=xlValues, LookAt:=xlPart)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy


"armadeus" wrote in message
...
Keeps giving the error 'First Instance not found' on a popup and doesn't
paste into worksheet.
"Tom Ogilvy" wrote in message
...
Sub OpenAndCopy()
Dim rng as Range, rng1 as Range
dim sh as Worksheet, bk as Workbook
set sh = Activesheet
set bk = Workbooks.Open("C:\MyFolder\Myfile.csv")
set rng = Columns(1).find(9135)
if not rng is nothing then
set rng1 = columns(1).find(9135,rng)
if not rng1 is nothing then
Range(rng,rng1).Entirerow.copy Destination:=sh.Range("A1")
else
msgbox "Second instance not found"
end if
else
msgbox "First Instance not found
End if
bk.close Savechanges:=False
End sub

--
Regards,
Tom Ogilvy

"armadeus" wrote in message
...
What I need is to open a text file, search through column A for a

specific
number lets say "9135". this number will appear twice in column A so

I
want
to copy everything between the instance of 9135 and paste in a

worksheet
in
the next available empty row. I am not a programmer and I am

completely
lost
any help would be appreciated!

Armadeus










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a text file Khawajaanwar Excel Discussion (Misc queries) 8 June 14th 05 12:58 PM
opening a text file BigD[_2_] Excel Programming 2 July 8th 04 01:14 AM
Opening text file in Excel Eric[_6_] Excel Programming 1 December 10th 03 05:18 PM
Opening Text File From internet mudraker[_34_] Excel Programming 0 November 24th 03 03:06 AM
when opening a text file.... Excel[_3_] Excel Programming 0 October 2nd 03 03:24 AM


All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"