try this see if it helps

Sub create_txtfile()
Dim arv, st1 As String
Dim s As Long, j As Long, k As Long

MyFile = "C:\Documents and Settings\user\Desktop\sample\ouputfile.txt"
'set and open file for output
With Sheets("Sheet1")
.Range("x:x").Clear
.Range("a1:a" & .Range("a1048576").End(xlUp).Row).AdvancedFilter
Action:=xlFilterCopy, CopyToRange:=.Range( _
"k1"), Unique:=True
End With

fnum = FreeFile()
Open MyFile For Output As fnum
Write #1,
For i = 2 To Sheets(1).Range("k65356").End(xlUp).Row
j = Application.WorksheetFunction.Match(Sheets(1).Range("k" & i).Value,
Sheets(1).Range("a:a"), 0)
k = Application.WorksheetFunction.CountIf(Sheets(1).Range("a:a"),
Sheets(1).Range("k" & i).Value) + j - 1
st1 = ""
arv = Sheets(1).Range("b" & j & ":b" & k)
For s = LBound(arv) To UBound(arv)
st1 = st1 & " " & arv(s, 1)
Next
st1 = Application.WorksheetFunction.Trim(st1)
Print #1, Chr(34) & Sheets(1).Range("k" & i).Value & Chr(34) & Chr(9) &
Chr(34) & st1 & Chr(34)
Next i
Close #fnum
End Sub




On Mon, Jul 2, 2012 at 12:00 PM, Ojemeni Uzoma <uojem...@gmail.com> wrote:

> **
> Hello Everyone,
>
> Kindly assist with a Macro.
>
> Thanks.
>
> Uzoma
> Ojemeni Uzoma | Call 08060700717
> ------------------------------
> *From: * OJEMENI Uzoma <uojem...@gmail.com>
> *Date: *Sun, 1 Jul 2012 19:02:25 +0100
> *To: *<excel-macros@googlegroups.com>
> *Subject: *$$Excel-Macros$$ Macro to populate "Output" file
>
> Hello Everyone,
>
> I would appreciate some assistance in creating a macro to export the
> content in the file "input" to the file output. The spacing, tabs and
> apostrophe should remain the same way as it is in the "output" file.
>
> Thank you everyone.
>
> Ojemeni Uzoma
>
>
>
>
>
>  --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>



-- 
*Regards*
* *
*Ashish Koul*
*http://www.excelvbamacros.com/*
*http://www.accessvbamacros.com/* <http://www.accessvbamacros.com/>


P Before printing, think about the environment.

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

Reply via email to