LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Comma delimited output for comments

Saving as *.csv means you would have to break out each sheet to its own
file.

To do what you want on all sheets in a workbook would require modifications
to iterate through the workbook sheet by sheet, inserting blank columns and
extracting the comments text, copying each sheet to a new workbook and save
that new workbook as *.csv

For starters this revision will extract the comments text to new blank
columns on each sheet in a workbook and save each sheet as its own
sheetname*.csv file.

Will overwrite existing workbooks of same name without warning.

To prevent that remove Applications.DisplayAlerts = False

Also edit the path to save in.

Sub ShowCommentsNextCell()
'based on code posted by Dave Peterson 2003-05-16
Application.ScreenUpdating = False
Application.DisplayAlerts = False 'remove if need warning

Dim commrange As Range
Dim mycell As Range
Dim Sh As Worksheet
Dim i As Long
Dim j As Long

Set Sh = ActiveSheet
i = Sh.Range(Cells(1, 1), Cells(Cells(1).Row, _
Columns.Count).End(xlToLeft)).Count

For Each Sh In ActiveWorkbook.Worksheets
On Error Resume Next
For j = i To 1 Step -1
Sh.Columns(j).Offset(0, 1).EntireColumn.Insert
Next j

Set commrange = Sh.Cells _
.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If commrange Is Nothing Then
MsgBox "no comments found"
Exit Sub
End If

For Each mycell In commrange
If mycell.Offset(0, 1).Value = "" Then
mycell.Offset(0, 1).Value = mycell.Comment.Text
End If
Next mycell
Sh.Copy
With ActiveWorkbook
.SaveAs Filename:="C:\yoursavefolder\" & _
Sh.Name & ".csv", FileFormat:=xlCSV
.Close
End With
Next Sh

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


Gord



On Thu, 18 Feb 2010 17:33:01 -0800, Michael Reach
wrote:

That's excellent, thank you. Now is there a way to run that macro on a whole
sequence of Excel files, or sheets? And is there a way to write them out to
.csv files automatically as well?
Thanks again,
Michael


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving as tab delimited or comma delimited MathGrace Excel Discussion (Misc queries) 0 June 20th 08 08:02 PM
Tab delimited to comma delimited Arne Hegefors Excel Worksheet Functions 3 December 13th 07 03:08 PM
Comma Delimited-need comma at beginnng & end Tattoo Excel Discussion (Misc queries) 2 December 11th 07 04:39 PM
Comma Delimited Numbers Spannerman Excel Discussion (Misc queries) 3 April 3rd 07 08:19 AM
Comma delimited question Carol Excel Discussion (Misc queries) 2 January 15th 05 11:32 AM


All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"