crobertson
New Member
- Joined
- Nov 14, 2005
- Messages
- 32
Ok,
This is working great, but here is my dilema, I now have to get a selection from a combo box + user input for the filename.
Any help is greatly appreciated!
Code:
Sub X()
SaveAsDelimited Range("'MAS90 Data'!A1:B4"), ","
End Sub
Sub SaveAsDelimited(Data As Range, Delimiter As String)
Dim Fname As Variant
Dim strBuf As String
Dim rngTemp As Range
Dim rngCell As Range
Dim intUnit As Integer
Dim strDelimit As String
Dim strPath As String
Dim strName As String
MsgBox "Please enter the job number as the filename."
Fname = Application.GetSaveAsFilename( _
fileFilter:="CSV (*.csv), *.csv")
If Fname = False Then
MsgBox "You didn't enter a filename!"
End If
intUnit = FreeFile
Open Fname For Output As intUnit
For Each rngTemp In Data.Rows
strBuf = ""
strDelimit = ""
For Each rngCell In rngTemp.Cells
If InStr(rngCell.Text, ",") > 0 Then
strBuf = strBuf & strDelimit & """" & rngCell.Text & """"
Else
strBuf = strBuf & strDelimit & rngCell.Text
End If
strDelimit = Delimiter
Next
Print #intUnit, strBuf
Next
Close intUnit
End Sub
This is working great, but here is my dilema, I now have to get a selection from a combo box + user input for the filename.
Any help is greatly appreciated!