Good Day Experts!
I need your help in creating my Merge Centre VBA program. Can you share the sample codes of your program? I need to create a short, simple but efficient Merge Centre program using VB 6.0 or VB .Net. If you're a Visual Basic expert then I need your expertise. Please share some of your knowledge.
Thank you so much,
Alison
Problem with Merge Centre VBA Codes?
Â
Hello Alison,
Â
There is a lot that you can do when it comes to merging cells in VBA program. Well, I will show you a sample merging program in VB 6.0.
Â
I created a file merge program where the user gives location of 2 text files. This code will be able to create a single merged file in a folder from where the application is running.
Â
Â
Sub MergeFiles()
Dim Txt As String, File1 As String, File2 As String, WriteFile As String
File3 = Trim(txt_SourceFile3)
File4 = Trim(txt_SourceFile4)
WriteFile = App.Path & "Merged_File.txt"
Â
On Error GoTo ErrHandler
Open File3 For Input As #3
Open WriteFile For Output As #4
Â
Do Until EOF(1)
  Line Input #3, Txt
  Txt = Trim(Txt)
  Print #4, Txt
Loop
Close #3
Â
Open File2 For Input As #3
Do Until EOF(1)
  Line Input #3, Txt
  Txt = Trim(Txt)
  Print #4, Txt
Loop
Close #3
Â
Close #4
MsgBox "Merged File Created: " & vbCr & WriteFile, vbInformation
Â
Exit Sub
ErrHandler:
MsgBox Err.Description, vbCritical
Reset
Err.Clear
End Sub
Â
I hope this gives you some sort of an idea on your ongoing Merge Centre.
Best of luck!
Â