Excel sort question. 
Author Message
 Excel sort question.

I am not an Office developer by nature so this question may seem simple, but
it eludes my current knowledge-set.

Lets say I have a spreadsheet with numerical data in one colum. I want to
output that data into a text file sorted without changing the data
arrangement in the original spreadsheet.

Here is some sample code to generate data in colum "A":

    Dim wb As Workbook
    Set wb = Application.ActiveWorkbook

    Dim ws As Worksheet
    Set ws = wb.ActiveSheet

    ' create some unsorted dummy data
    ws.Range("a1") = "2"
    ws.Range("a2") = "4"
    ws.Range("a3") = "6"
    ws.Range("a4") = "8"
    ws.Range("a5") = "0"
    ws.Range("a6") = "1"
    ws.Range("a7") = "3"
    ws.Range("a8") = "5"
    ws.Range("a9") = "7"
    ws.Range("a10") = "9"

This next line of code does sort of what I want, but the sort does not
happen in memory, it actually changes the spreadsheet which I do not want to
happen.

    ws.Range("a1:b10").Sort Range("a1"), xlAscending

So how can I do this in memory so I in effect do not change any of the
original data (or its order) on the spreadsheet. Should be simple.
TIA



Fri, 04 Mar 2005 21:02:17 GMT  
 Excel sort question.

Can you just copy the data to another worksheet, sort that worksheet,
and then output to the text file?

--
Posted via http://dbforums.com



Tue, 08 Mar 2005 22:43:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBA/Excel questions; Sorting and Printer Selection

2. Sort order - Edit Filter Sort or Quick Sort

3. Problem in running Excel sort function in Access using VBA

4. Excel Sorting

5. Sorting of excel-tables

6. excel sheet-need sort 2 col's and total the last by date

7. sorting rows in an excel file

8. VBA Excel sorting problem

9. Please Help with VB Sort Command in Excel

10. SORTING IN EXCEL

11. VBA Excel Listbox and Sort

12. Sorting Excel sheets from VB

 

 
Powered by phpBB® Forum Software