# Need Macro To Copy & Sort

• Hi, below is a specification for a macro that I need coded for Excel2000.
Many thanks in advance for any help.

Sub QUERYSORT ()

------------------------------------------------------------------------------------
Sub Routine - Section1:
------------------------------------------------------------------------------------
Find Range - LAST COLUMN of "Temp" worksheet that contain text:

Find all cells that contain text and copy them to "Results0" worksheet/columnA
Sort Cells numerically/alphabetically (RowA contains 001[*], RowB contains 002[*], etc.)

Find Range -2ND TO LAST COLUMN of "Temp" worksheet that contain text:

Find all cells that contain "]1" and cut them to "Results1" worksheet/columnA
Sort Cells numerically/alphabetically
Find all cells that contain "]2" and cut them to "Results2" worksheet/columnA
Sort Cells numerically/alphabetically
Find all cells that contain "]3" and cut them to "Results3" worksheet/columnA
Sort Cells numerically/alphabetically

------------------------------------------------------------------------------------
Sub Routine - Section2:
------------------------------------------------------------------------------------
Find Range - "Results3" worksheet/columnA,row2:
find exact matching cell in "Matrix" worksheet
Select MatrixWorksheet-columnsA-F of that row (the row that contains the matching cell).
Copy cells to "Results3" worksheet/columnsB-G,row2.

Repeat this process for all rows containing text (in the "Results3"worksheet),
copying results to the columnsB-G of the row of the cell that was queryed.

Find/Replace: AnyStringOfNumbers LEFT of a bracket within any cell
(example: "001[" , "002[" , etc.)
Replace: with nothing (example, Find: "001[" Replace: "" )

Find/Replace: AnyStringOfNumbers RIGHT of a bracket within any cell
(example: "]1" , "]2" , etc.)
Replace: with nothing (example, Find: "]1" Replace: "" )

Find/Replace: Find any commas, and replace them with a space. (Find: "," Replace " ")

------------------------------------------------------------------------------------

Repeat "Sub Routine - Section2"
for worksheets "Results2", "Results1", "Results0".

Clear the contents of "Temp"worksheet.

End Sub

Thankyou,
Jim

• This is a lot to ask, I didn't think about that at the time I posted. I'm an artist/designer, and if someone needs any artwork (logo or something) in return, I would be more than happy to provide. Or, if someone has a fee, let me know your price, and I'll see if I can afford it.

Or, maybe my question should be this:
How can you get the Excel Macro recorder to copy and paste , or select cells dynamically?

Example1: if I copy the contents of cell A1 to cell B1, how can I make it copy what is in cell A1 at the time I run the macro, not at the time I recorded it.

Example2: If a macro finds something, and I want it to select certain columns in the row that it found in, how can I do that? The recorder won't do that (that I know of).

Thanks,

Jim

• Re: Need Macro To Copy &amp; Sort

This macro collects 3 columns of data Columns A thru C(approx. 2500 row entries) which are tabulated numerically by column A
It copies them to another area of the spreadsheet, (Column G)and sorts them alphbetically using Column I (which contains Text data) as the sorting criteria.

The second code selects the pasted material and clears it. always leaving your initial data intact.

Clearing Macro:

Code
``````Sub QwikListClear()
Range("G6").Select
ActiveCell.SpecialCells(xlLastCell).Select
Range("G6").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Clear
Range("A6").Select

End Sub``````

Hope this is of some help, although it may not be what you were looking for. I had some difficulty comprehending exactly what you were wanting to accomplish.
I too am not a programmer, but a Draftsman / Graphic artist, so some of this Excel can be very overwhelming.
Good Luck.

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!