Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need a macro!!!

Posted on 2003-11-03
9
Medium Priority
?
385 Views
Last Modified: 2010-04-17
how can I write a macro either in Excell 2000 or VB to do the following work for me:
 XXXXXX will change to XXXX, BB, XX
AAAAAA  will change to AAAA BB AA
 I mean that I have a very big file that has about two thousand lines and each line has six characters (letters and
numbers only).
 I need tochange them inthis way:
 First the first four characters then a camma then BB then
 camma then the last two charachters of the same line.
 this must be done more than 2000 times !!!!
 and some times I need to do it just in half an hour !!!
 I must say that the original file is text file, but can be opened
 with Excell, word, ....
thanks in advance.
0
Comment
Question by:Ren_kha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 9676564
Is this always the same changes?
You could do it by hand for 1 line while recording a macro.
Does Search and replace not work?

mlmcc
0
 
LVL 1

Expert Comment

by:nigelbe
ID: 9676725
is it a normal text (.TXT) file?

0
 
LVL 53

Expert Comment

by:Dhaest
ID: 9676735
Just replace your old and new filename in the open-statement

sub ChangeFile
Dim fh, fh2 As Integer
Dim line As String
fh = FreeFile
fh2 = fh + 1
Open "c:\test.txt" For Input As #fh
Open "c:\test3.txt" For Random As #fh2

Do While Not EOF(fh)
  Line Input #fh, line
  line = Left(line, 4) & ", BB, " & Right(line, 2)
  Put #fh2, , line
Loop

Close fh
Close fh2
end sub
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Ren_kha
ID: 9676778
Dear mlmcc,
 To be honest I am going to need more Macros in future. So,
 please tell me about your method to enable me to write Macros.
 Thanks.
 Reno.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 9676789
Fe: in Word
Tools - Macro - record new macro.
Now you can do whatever you want. It will be recorded and so you can recall it through tools - macro - macros
0
 

Author Comment

by:Ren_kha
ID: 9676802
dear Nigelbe,
 Thanks for your attention. It is allways a text file. But I can
 open it with any thing such as Excell, Word, notepad, wordpad.
 Since, it is only lletters and numbers and cammas (,,,,,).
 hope that you can give me some more advice.
 Thanks,
 Reno.
0
 

Author Comment

by:Ren_kha
ID: 9676820
Dear Dhaest,
 many thanks for your quick replies.
 I was just going to ask my question but you kindly answered it.
 So it will work in EXCELL 2000.
 Again let me thank you.
 Yours,
 Reno.
 
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 1000 total points
ID: 9676824
Normally it should work with excell, word, .... because I didn't use any special things.
0
 

Author Comment

by:Ren_kha
ID: 9676853
Dear Dhaest,
 Many thanks for your quick action.
 I hope to have your help in future again.
 Yours,
 Reno.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question