J
Jorgen Bondesen
Hi NG
I'm using bellowed macro.
Each time I'm opening my User Form = UF, I must rum this macro for getting
array: data()
Is there a way I can load the Array [data()] in memory, so I only run the
macro when opening the file and Erase data() when closing the file?
Option Explicit
Public Const Delim As String = " ¿ "
Public Const hil As String = "Best regards from Joergen"
'// Array for form
Public data() As Variant
'----------------------------------------------------------
' Procedure : Form
' Date : 20110227
' Author : Joergen Bondesen
' Modifyed by :
' Purpose :
' Note :
'----------------------------------------------------------
'
Sub Form()
Dim sh As Worksheet
Set sh = Sheets(2)
Dim RRange As Range
Set RRange = sh.Range("A1:A" & _
sh.Cells(sh.Rows.Count, 1).End(xlUp).Row)
Dim Countarr As Long
Countarr = 0
Dim cell As Range
For Each cell In RRange
Dim Uniqs As New Collection
On Error Resume Next
Uniqs.Add cell.Value, CStr(cell.Value)
If Err = 0 Then
Countarr = Countarr + 1
ReDim Preserve data(1 To Countarr)
data(Countarr) = cell.Value & Delim _
& cell.Offset(0, 1) & Delim & cell.Offset(0, 2)
End If
On Error GoTo 0
Next cell
Load UF
UF.Show
Set sh = Nothing
Set RRange = Nothing
End Sub
I'm using bellowed macro.
Each time I'm opening my User Form = UF, I must rum this macro for getting
array: data()
Is there a way I can load the Array [data()] in memory, so I only run the
macro when opening the file and Erase data() when closing the file?
Option Explicit
Public Const Delim As String = " ¿ "
Public Const hil As String = "Best regards from Joergen"
'// Array for form
Public data() As Variant
'----------------------------------------------------------
' Procedure : Form
' Date : 20110227
' Author : Joergen Bondesen
' Modifyed by :
' Purpose :
' Note :
'----------------------------------------------------------
'
Sub Form()
Dim sh As Worksheet
Set sh = Sheets(2)
Dim RRange As Range
Set RRange = sh.Range("A1:A" & _
sh.Cells(sh.Rows.Count, 1).End(xlUp).Row)
Dim Countarr As Long
Countarr = 0
Dim cell As Range
For Each cell In RRange
Dim Uniqs As New Collection
On Error Resume Next
Uniqs.Add cell.Value, CStr(cell.Value)
If Err = 0 Then
Countarr = Countarr + 1
ReDim Preserve data(1 To Countarr)
data(Countarr) = cell.Value & Delim _
& cell.Offset(0, 1) & Delim & cell.Offset(0, 2)
End If
On Error GoTo 0
Next cell
Load UF
UF.Show
Set sh = Nothing
Set RRange = Nothing
End Sub