LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default 2 Collection questions

The following code runs, but the Collection "VatCodes" holds no values
on completion:

With ws
FirstRow = .Range("M2").Row
LastRow = .Range("M65536").End(xlUp).Row
If LastRow = 2 Then GoTo Line2
.Unprotect
.Select

Set DataRange = .Range("M" & FirstRow, "M" & LastRow)
'use OERN otherwise an error will be thrown for duplicate entries
'in the Collection
On Error Resume Next
For Each R In DataRange
If Not IsEmpty(R) Then
VatCodes.Add R.Value
End If
Next
End If
End With

Q1: Why has the Collection failed to build please?

The following code will sort a Collection numerically:

For i = 1 To VatCodes.Count - 1
For j = i + 1 To VatCodes.Count
If VatCodes(i) VatCodes(j) Then
Swap1 = VatCodes(i)
Swap2 = VatCodes(j)
VatCodes.Add Swap1, Befo=j
VatCodes(wsCtr).Add Swap2, Befo=i
VatCodes.Remove i + 1
VatCodes.Remove j + 1
End If
Next j
Next i

Q2: How can I sort a Collection alphabetically please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.571 / Virus Database: 361 - Release Date: 26/01/2004


 
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
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
Does anybody have a CD collection template PeterM Excel Discussion (Misc queries) 2 November 27th 04 05:46 PM
sheet collection Tom Ogilvy Excel Programming 0 October 28th 03 03:15 PM
Is a Collection the best option? Bradley Dawson Excel Programming 1 August 31st 03 08:14 PM


All times are GMT +1. The time now is 04:48 AM.

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"