Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Save & Load A Range


Wonder if something like this is possible - 'air' code to show
example.
--
Dim zz As Range
Set zz = Worksheets("Sheet1").Range("S760:CD760")

Open "c:\test" for output as #1
print # 1, zz
Close 1

Then,

Open "c:\test" for input as #1
get # 1, zz
Close 1
--

I suspect I may need to do this

Dim c as Range
Open "c:\test" for output as #1

For Each c In zz
print # 1,c.Value
Next c
Close 1

And

Open "c:\test" for input as #1
Do
line input # 1, zz
Somehow put zz back into the range ???
loop until eof(1)
Close 1

--

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Save & Load A Range

I am not sure of exactly what you are trying to do with the code you have
listed...

It appears as if you are wanting to print certain information to a test
file, and also load it back into memory?

Is this correct?

If so, what I would do is (while you are sending it to a test file) also
load this information into an array which can be referenced later in your
code.

If this sounds like something you are wanting to do (and cannot figure it
out) just let me know and I will see what I can do to help out.

It would really help out if you could post all your code so I could better
see how to help out.

Mark Ivey




"kirkm" wrote in message
...

Wonder if something like this is possible - 'air' code to show
example.
--
Dim zz As Range
Set zz = Worksheets("Sheet1").Range("S760:CD760")

Open "c:\test" for output as #1
print # 1, zz
Close 1

Then,

Open "c:\test" for input as #1
get # 1, zz
Close 1
--

I suspect I may need to do this

Dim c as Range
Open "c:\test" for output as #1

For Each c In zz
print # 1,c.Value
Next c
Close 1

And

Open "c:\test" for input as #1
Do
line input # 1, zz
Somehow put zz back into the range ???
loop until eof(1)
Close 1

--

Thanks - Kirk


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Save & Load A Range

On Sun, 20 Apr 2008 06:29:10 -0500, "Mark Ivey"
wrote:

I am not sure of exactly what you are trying to do with the code you have
listed...

It appears as if you are wanting to print certain information to a test
file, and also load it back into memory?

Is this correct?

If so, what I would do is (while you are sending it to a test file) also
load this information into an array which can be referenced later in your
code.

If this sounds like something you are wanting to do (and cannot figure it
out) just let me know and I will see what I can do to help out.

It would really help out if you could post all your code so I could better
see how to help out.

Mark Ivey


Hi Mark,

The 'big picture' is to export a column to a file and import it into
another xls. (on a different computer).

It wondered if I could keep it as range, to avoid a Do or For loop
as each item was processed. It seemed it might be an efficent
method.

I then found you couldn't print# a range.

So I guess a simple, basic loop is the way to go?

Cheers - Kirk
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Save & Load A Range

Here is an example you can look over to see if it may fit your needs...

Mark Ivey



Option Explicit

Sub test()
Dim myArray(65000) As String
Dim LastRow As Long
Dim i As Long
Dim myTextFile As Variant
Dim fnum As Variant
Dim originalWBName As String

' Two features to make the code run
' more efficiently
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

' Get original WB Name
originalWBName = ActiveWorkbook.Name

' Find last row of data
LastRow = Range("A1").End(xlDown).Row

' Load the array
For i = 1 To LastRow
myArray(i) = Cells(i, 1).Value
Next

' Set and open a text file
myTextFile = "c:\" & "TEXTING123456.txt"
fnum = FreeFile()
Open myTextFile For Output As fnum

' Write array to text file
For i = 1 To LastRow
Print #fnum, myArray(i)
Next

' Close text file
Close #fnum

' Open blank workbook
Workbooks.Add

' Save it back to C Drive
' I added date and time to filename
' to avoid duplicate file errors
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\myTestWorkbook_" & _
Format(Now, "ddmmyyyy_hhmmss") & ".xls"

' Put array values into same column
' on new workbook
For i = 1 To LastRow
Cells(i, 1).Value = myArray(i)
Next

' Save the new file
ActiveWorkbook.Save

' Set focus back to original WB
Workbooks(originalWBName).Activate

' Turn efficiency features back to normal
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Save & Load A Range

On Mon, 21 Apr 2008 04:04:22 -0500, "Mark Ivey"
wrote:

Thanks very mucjh, Mark.

Have everything working nicely.




Here is an example you can look over to see if it may fit your needs...

Mark Ivey



Option Explicit

Sub test()
Dim myArray(65000) As String
Dim LastRow As Long
Dim i As Long
Dim myTextFile As Variant
Dim fnum As Variant
Dim originalWBName As String

' Two features to make the code run
' more efficiently
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

' Get original WB Name
originalWBName = ActiveWorkbook.Name

' Find last row of data
LastRow = Range("A1").End(xlDown).Row

' Load the array
For i = 1 To LastRow
myArray(i) = Cells(i, 1).Value
Next

' Set and open a text file
myTextFile = "c:\" & "TEXTING123456.txt"
fnum = FreeFile()
Open myTextFile For Output As fnum

' Write array to text file
For i = 1 To LastRow
Print #fnum, myArray(i)
Next

' Close text file
Close #fnum

' Open blank workbook
Workbooks.Add

' Save it back to C Drive
' I added date and time to filename
' to avoid duplicate file errors
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\myTestWorkbook_" & _
Format(Now, "ddmmyyyy_hhmmss") & ".xls"

' Put array values into same column
' on new workbook
For i = 1 To LastRow
Cells(i, 1).Value = myArray(i)
Next

' Save the new file
ActiveWorkbook.Save

' Set focus back to original WB
Workbooks(originalWBName).Activate

' Turn efficiency features back to normal
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Save & Load A Range

On Mon, 21 Apr 2008 04:04:22 -0500, "Mark Ivey"
wrote:

Here is an example you can look over to see if it may fit your needs...

Mark Ivey



Thanks very much, Mark.

I've everything running nicely.

Interesting to see the efficiency features method.
Hadn't seen that before.

Cheers - Kirk
Reply
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
A save/load txt UserForm Abe[_4_] Excel Programming 3 July 27th 06 10:16 PM
Save/Load txt files UserForm question Abe[_4_] Excel Programming 1 July 7th 06 12:20 AM
How to d/load & save web pages w/VBA? Ron[_14_] Excel Programming 0 April 13th 06 07:49 PM
avoiding Load/Save Dialog Vishesh Vyas Charts and Charting in Excel 0 June 21st 05 01:37 PM
Excel is very slow to load/save the spreadsheet Simon Ren Excel Programming 3 July 8th 03 10:21 PM


All times are GMT +1. The time now is 11:15 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"