Hi, I am trying to figure out how to print a line based on if the cell value = 'y'. I thought I can use switch statment as there is about 40 rows that I need to check if column 'J' is set to 'y' in the cell. If it does that I need to print the line or skip if it is set to 'n'.
Would I use a if statement to accomplish this?
Thanks
Below is my code and screenshot (column J):
Would I use a if statement to accomplish this?
Thanks
Below is my code and screenshot (column J):
VBA Code:
Sub CellsToFreedom()
On Error GoTo ErrorHandler
Dim freedomfile As String: freedomfile = ThisWorkbook.Path & "\FromTemplate.txt"
Dim fso As Scripting.FileSystemObject: Set fso = New Scripting.FileSystemObject: Dim ts As Scripting.TextStream
Set ts = fso.OpenTextFile(freedomfile, ForWriting, True)
Dim tmp As String, pd As String, jd As String, source As String
tmp = tmp & MakeLine(Cells(6, 1).Value & Cells(6, 2) & Cells(6, 3) & Cells(6, 4).Value & "00", source & "" & pd, Cells(6, 6).Value)
ts.Write (tmp)
MsgBox "Freedom file was created."
writelog "file was created."
ExitHere:
ts.Close
Exit Sub
ErrorHandler:
writelog Err.Description & " " & Err.Number, "CellsToFreedom()", False
Resume ExitHere
End Sub