# Off Topic > Hello..Introduce yourself >  >  VBA macro replacement using a VBA procedure.

## JOHNWRICHARDSNZ

I like Excel VBA for its macro recording function and it's programmable. I have been using it for a decade.

----------


## arlu1201

Hello JOHNWRICHARDSNZ, 

Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.

----------


## JOHNWRICHARDSNZ

During development I would like to run a VBA procedure able to generate and put macro code text into an existing module so it's ready to run when needed. But not into the same module as the generator obviously.

Thus I need a VBA procedure that can copy text of new VBA code from a generated worksheet into an existing VBA procedure so that it will run when the program is executed.

I have a VBA procedure that generates new VBA code text into a worksheet. The new VBA code is to replace old similar code in an existing VBA procedure 

(preferably within a subroutine or function or as one). The new code could replace the contents of a whole VBA module if necessary, (delete and paste).

The new code concerned is from VBA interpreting a Decision Table worksheet into a SELECT CASE statement on a worksheet. 

Sample new code:

SelectCase: '   as made by running Example1 for the decision table with GENERATED CODE on for VBA
    Windows(FileName).Activate

' start of code generated by the decision table processor
    Select Case True
        '' Case 1
        Case ((Trim(WageMore) > "") = False) And (Trim(RentMore) > "") And (Trim(Paid_More) > "") _
        And (RentDueDate <= Paid_Date)
            GoSub ProcessRentLine: GoSub BalanceRowOut

        '' Case 2
        Case ((Trim(WageMore) > "") = False) And (Trim(RentMore) > "") And (Trim(Paid_More) > "") _
        And ((RentDueDate <= Paid_Date) = False)
            GoSub ProcessPaidLine: GoSub BalanceRowOut

        '' Case 3
        Case ((Trim(WageMore) > "") = False) And (Trim(RentMore) > "") And ((Trim(Paid_More) > "") = False)
            GoSub ProcessRentLine: GoSub BalanceRowOut
' . . . 
        '' Case 14
        Case ((Trim(WageMore) > "") = False) And ((Trim(RentMore) > "") = False) And ((Trim(Paid_More) > "") = False)
            '' Do loop handles it

        Case Else
              Stop    '   unexpected result
    End Select
' end of code generated by the decision table processor

Return

----------


## arlu1201

You will need to post your question in the main forum.  This is for introductions only.

----------

