Code:
Private Sub CommandButton1_Click()
Dim xWs As Worksheet
Dim xcsvFile As String
Dim rCell As Range
Dim rRow As Range
lFnum As Long
Dim rowCount As Long
For Each xWs In Application.ActiveWorkbook.Worksheets
For Each rRow In ActiveWorkbook.UsedRange.Rows
If rowCount > 1 Then
For Each rCell In rRow.Cells
xcsvFile = xcsvFile & rCell.Text & ";"
Next rCell
xcsvFile = Left(xcsvFile, Len(xcsvFile) - 1)
Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=lFnum"]#lFnum[/URL] , xcsvFile
MsgBox rRow.Row & vbCrLf & xcsvFile
xcsvFile = CurDir & "" & xWs.Name & ".csv"
Application.ActiveWorkbook.SaveAs Filename:=xcsvFile, _
FileFormat:=xlCSV, CreateBackup:=False
Application.ActiveWorkbook.Saved = True
Application.ActiveWorkbook.Close
End If
rowCount = rowCount + 1
Next rRow
End Sub
This is giving compile error. statement invalid outside Type block
Last edited by a moderator: