Skip to main content

chat1

FunctionSub OnlyContainsItems(arr()AppendStringToFile(cleanedString As Variant, item1 As Variant, item2 As Variant) As BooleanString)
    Dim itemfileNum As VariantInteger
    ForDim EachsanitizedString itemAs In arrString
    IfDim itemfilename <>As item1 And item <> item2 ThenString
    OnlyContainsItems
    ' Hard-coded filename
    filename = False"C:\path\to\your\file.txt" ' Replace with your desired file path
    Exit Function
    End' IfRemove newlines (vbCr, vbLf, vbCrLf) from the input string
    NextsanitizedString item= Replace(cleanedString, vbCrLf, "")
    OnlyContainsItemssanitizedString = TrueReplace(sanitizedString, vbCr, "")
    sanitizedString = Replace(sanitizedString, vbLf, "")
    
    ' Get a free file number
    fileNum = FreeFile
    
    ' Open the file for appending
    Open filename For Append As #fileNum
    
    ' Write the sanitized string to the file, followed by a newline
    Print #fileNum, sanitizedString
    
    ' Close the file
    Close #fileNum
End FunctionSub