Consulting

Results 1 to 5 of 5

Thread: Rename Thousands of Recipe *.txt files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2018
    Posts
    3
    Location

    Rename Thousands of Recipe *.txt files

    [QUOTE=fumei;219234]First off...
    Then the code should go through IF statement with the following rules.
    If keyword=”chief complaint”, make variable “T_Document”= chart_note
    IF keyword=”billing statemen”t, make variable “T_Document”=billing statement
    IF keyword=“Mark Gventer, D.P.M., F.A.C.F.O.”, make variable “T_Document”=prescription
    If keyword=”DAILY SIGNATURE FORM”, make variable “T_Document”=daily signature
    If keyword=“PRIVACY PRACTICES ACKNOWLEDGEMENT”, make variable “T_Document”=privacy
    [/quote}No! Do not use an bu7nch of IF statements. This is precisely wehat Select Case is used for. Here is why.

    ALL your IF statements will be executed, because they are independent instructions - there is NO inherent logic linking then (at least to VBA). Here is the same result using Select Case:[vba]
    ' Then the code should go through with the following rules.
    Select Case keyword
    Case ”chief complaint”
    T_Document = "chart_note"
    Case ”billing statement"
    T_Document = "billing statement"
    Case “Mark Gventer, D.P.M., F.A.C.F.O.”
    T_Document = "prescription"
    Case ”DAILY SIGNATURE FORM”
    T_Document = "daily signature"
    Case "PRIVACY PRACTICES ACKNOWLEDGEMENT”
    T_Document = "privacy"
    End Select
    [/vba]Select Case testing multiple values for the same variable - in this case, the variable keyword (I am not happy with that name though, as it seems close to being a restricted term)

    As for: "Then I need to go through the text that is pasted by function Selection.Paste (please see the code above) "

    I do not follow. There is a Sub above (not a Function). And I am unclear as to what it is doing. Using Selection is not a good idea.

    BTW: I do not know if your posted file has macros, as I do not use 2007, and convertin git strips all code.


    Moderator Edit: This refers to :http://www.vbaexpress.com/forum/showthread.php?32476
    Last edited by SamT; 03-17-2018 at 01:49 PM.

Posting Permissions

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