Consulting

Results 1 to 2 of 2

Thread: Append an order number in a text file with a string and then save

  1. #1
    VBAX Newbie
    Joined
    Nov 2018
    Posts
    1
    Location

    Append an order number in a text file with a string and then save

    Hi all,
    I am new to VBA and the forum but I have a problem in our business that I am trying to solve.

    We have a Tab delimited text file that contains an order number that will be sent to a vendor. Before we send it, we need to append each order number with a string of text. i.e "abc18".

    The current process is to import the text file into Excel, Concatenate the text into the order column and then export that back out into a text file. I was hoping to automate this with VBA.

    I've been able to automate importing the text file into Excel but I know there has to be an easier way that will not require the user to activate three separate Macros to complete the task:

    Option Explicit
    Sub ImportTextFile()
    Dim vFileName


    On Error GoTo ErrorHandle


    vFileName = Application.GetOpenFilename("Text Files (*.txt),*.txt")




    If vFileName = False Or Right(vFileName, 3) <> "txt" Then
    GoTo BeforeExit
    End If
    Application.ScreenUpdating = False
    Workbooks.OpenText Filename:=vFileName, _
    Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    xlDoubleQuote, Tab:=True


    BeforeExit:
    Application.ScreenUpdating = True
    Exit Sub
    ErrorHandle:
    MsgBox Err.Description
    Resume BeforeExit
    End Sub

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    You can easily "combine" several macros by inserting a call to the next macro :

    Option Explicit
    
    
    Sub MacroOne()
    
    
        'your macro code
    
    
        MacroTwo
    
    
    End Sub
    
    
    
    
    Sub MacroTwo()
    
    
        'your macro code
    
    
        MacroThree
    
    
    End Sub
    
    
    
    
    Sub MacroThree()
    
    
    '   your macro code
    
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •