Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Saving as tab delimited or comma delimited | Excel Discussion (Misc queries) | |||
Tab delimited to comma delimited | Excel Worksheet Functions | |||
Comma Delimited-need comma at beginnng & end | Excel Discussion (Misc queries) | |||
Comma Delimited Numbers | Excel Discussion (Misc queries) | |||
Comma delimited question | Excel Discussion (Misc queries) |