LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Problems with saving cell values to file

(Sorry, if my message arrives twice. I can't see the first one.)


Const SaveTheseCells As String = "M4:O4;M6:O6;M8:O8;M10:O10;M12:O12"

Sub SaveToFile()
Dim MySheet As Worksheet

For Each MySheet In ActiveWorkbook.Worksheets
Select Case MySheet.CodeName
Case "SpecialSheet":
Dim SheetToFile As Worksheet
Set SheetToFile = MySheet
End Select
Next MySheet

Set MySheet = Nothing

Dim FileName As String
FileName = "C:\test.txt"

FileNum = FreeFile

Open FileName For Output As #FileNum
Print #FileNum, "start"

SheetToFile.Range(SaveTheseCells).Select

Dim cell As Range

'This does not save the values of M4, N4, O4, etc.
'What is wrong with this?

For Each cell in Selection.Cells
Print #FileNum, cell.Text
Next cell

Print #FileNum, "end"
Close #FileNum

Set SheetToFile = Nothing
End Sub
 
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
Problems with saving a Excel file Just Me[_2_] Excel Discussion (Misc queries) 2 November 4th 07 01:54 AM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
Saving a file with a name generated by cell values analyst Excel Programming 5 September 16th 04 03:49 PM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
Saving a file(new) using the multiple cell contents as a file name Dave Peterson[_3_] Excel Programming 1 August 1st 03 01:40 PM


All times are GMT +1. The time now is 02:37 PM.

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"