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: 11
Default How to maintain size of array: UniqRow

Hi NG

I need help.
I can not maintain (lock) the array: UniqRow
Look below at my comment (remarks) in the macro, please.


Option Explicit


'----------------------------------------------------------
' Procedure : AvoidNowithX
' Date : 20110802
' Author : Joergen Bondesen
' Modifyed by :
' Purpose : Avoid duplicats in Column A (row) if X in
' Column C. Copy none x number to Column D
' Note : X = x.
' Column A = Number
' Columm B = Not in use
' Column C = "X"
' Column D = Alle Numbers without X
'----------------------------------------------------------
'
Sub AvoidNowithX()

Application.ScreenUpdating = False

'// Getting Range
Dim RRange As Range
Set RRange = Range("A2:A" & Cells(Rows.count, 1).End(xlUp).Row)

'// Finding "X" numbers
Dim cell As Range
For Each cell In RRange
On Error Resume Next
If UCase(cell.Offset(0, 2).Value) = "X" Then
Dim UniqRow As New Collection
UniqRow.Add Item:=cell, Key:=CStr(cell)
Application.StatusBar = cell.Row & " Uniq"
End If
On Error GoTo 0
Next cell

'// Trying to "lock" UniqRow, but it do not work
Set UniqRow = UniqRow

Dim Uniq As Double
Uniq = UniqRow.count

If Uniq 0 Then
'// Avoid calculation
Dim xlCalc As XlCalculation
xlCalc = Application.Calculation
Application.Calculation = xlCalculationManual
On Error GoTo CalcBack

Dim UniqRow2 As New Collection

For Each cell In RRange

'// Just testing
Uniq = UniqRow.count

'// Just testing
Dim Uniq2 As Double
Uniq2 = UniqRow2.count

'//
On Error Resume Next
'// If number can be added, it goes to column D
UniqRow2.Add Item:=cell, Key:=CStr(cell)
If Err.Number < 0 Then

Else

Dim count As Long
count = count + 1

Cells(count + 1, 4).Value = cell.Value

Application.StatusBar = cell.Row & " Next"
End If

'// Clear error
Err.Clear

'// trying to reset
Set UniqRow2 = Nothing

'// Get the original array, but it is changed when I add a value.
PROBLEM
Set UniqRow2 = UniqRow

On Error GoTo 0
Next cell

Application.Calculation = xlCalc

End If

CalcBack:

Application.Calculation = xlCalc

Set RRange = Nothing
End Sub



--
Best regards
Jorgen Bondesen


 
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
Saving chart as picture - how to maintain the same size of the fil Martin Charts and Charting in Excel 3 February 22nd 08 06:03 PM
Maintain the Excel chart size after pasting into Word Rob W Excel Discussion (Misc queries) 1 February 19th 06 03:35 PM
How to find out the size of a variable-size array ? Adrian[_7_] Excel Programming 1 July 6th 04 09:12 AM
Array Size Srinath Excel Programming 4 August 15th 03 07:58 PM
Array size ten Excel Programming 6 August 12th 03 09:16 AM


All times are GMT +1. The time now is 01:27 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"