Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A save/load txt UserForm | Excel Programming | |||
Save/Load txt files UserForm question | Excel Programming | |||
How to d/load & save web pages w/VBA? | Excel Programming | |||
avoiding Load/Save Dialog | Charts and Charting in Excel | |||
Excel is very slow to load/save the spreadsheet | Excel Programming |