Forum Discussion
Sorting data
So I tried this (thankyou v.much :) Logaraj Sekar )
I tried it on a new set of data - it worked but pulled out 30 CSV files.
When I did it manually there are only 2 spreadsheets.
Any ideas? I dont know anything about VBA code so not sure where to start.
Thanks
:)
Hi Laura,
Based on the RD reference, i created macro. So it will count no of RD references (without duplication).
If RD reference count is 30, it will create 30 Sheets. In case you need change, explain it i will do changes in macro.
- LauraDaisyMay 10, 2018Copper Contributor
I think there may have been some confusion in what I'm trying to do.
I have a data set of 600 lines of transaction data with dates and references. In that, 100 are duplicate reference numbers but have different transaction dates. All the rest are unique reference numbers.
I need to move the data so that one csv. file doesn't contain the same reference number.
When I do it manually, I ended up with 3 csv. files - 1 ) of 500 lines, 2 ) of 63 lines, 3) of 37 lines.
Then I can import in bulk.
Does that make sense?
if it can be done it would be awesome as manually is quite time consuming and requires several checks to ensure no mistake on my part.
Thanks :)
- Logaraj SekarMay 10, 2018Steel Contributor
Hi LauraDaisy
You are telling that, of which 600 lines, you moving them to 3 CSV files.
500 Lines in one CSV, 63 Lines in another CSV and remaining in another CSV.
I think i forget to write code for sorting in Macro. So that it creates 30 files instead of 3.
Please sort it manually and run macro (or) add these lines after third line in Macro. It will automatically sort the data.
Note: Here "Sheet1" refers name of the sheet. Change it to your sheet name
Range("A1:E" & b).Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("D2:D" & b), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:E" & b)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With- LauraDaisyMay 11, 2018Copper Contributor
Logaraj Sekar is that the actual 3rd line, or the 3rd group of code?
This is also raising debug issues (see file attached)