View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default macro save given range to .xlw

One way:

Assume: save from row 2 down, name to come from A1

Public Sub NoHiddenCSV()
Const DELIMITER As String = ","
Dim myRecord As Range
Dim myField As Range
Dim sOut As String

Open Range("A1").Text & ".csv" For Output As #1
For Each myRecord In Range("A2:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
If Not myRecord.EntireRow.Hidden Then
With myRecord
For Each myField In Range(.Cells, _
Cells(.Row, Columns.Count).End(xlToLeft))
If Not myField.EntireColumn.Hidden Then _
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #1, Mid(sOut, 2)
sOut = Empty
End With
End If
Next myRecord
Close #1
End Sub



In article ,
(topas) wrote:

Please help me with a macro which saves the active worksheet to a
.csv file with the filename to choose or with the filename to get from
a specific cell.
the active worksheet contains hidden areas which must not be saved.

Thanks

Juergen Kimmel