Hi all
due to an addition of data in a control workbook the displayed elements in a dynamic userform, (courtesy of GregM from this site), have become too many to display due to screen size. As a workaround to avoid a major redesign I want to limit a displayed column by splitting it into 2.
The problem is though that if the date elements are not present in column 3 they are lost to many other sections of the database.
It is for that reason, as the the array is collected, or just before completion, I would like to limit the elements in Column 3 by deleting (or not adding to array) if a date entry also appears in column 6. I'm not sure does this fall into the category of redimming the first element of an array.
Limiting their entry into to the array is probably the way to go and I'll keep looking at that.
Any pointers appreciated, I have tried a few methods including limiting the number of rows when dealing when column3 but none successful.
The array is collection by UDF
Option Private Module
Option Explicit
'=========================================================================================
'=========================================================================================
Public Sub ShowForm3()
Const iWARNING_DAYS As Integer = 100
Dim vaEmployeeData As Variant
Dim frm As F04_SafeData
vaEmployeeData = mvaEmployeeData()
Set frm = New F04_SafeData
With frm
.EmployeeData = vaEmployeeData
.WarningDays = iWARNING_DAYS
.Show
End With
Unload frm
Set frm = Nothing
End Sub
'=========================================================================================
'=========================================================================================
'=========================================================================================
'=========================================================================================
Private Function mvaEmployeeData() As Variant
Dim vColumnNo_Worksheet As Variant
Dim iColumnNo_Worksheet As Integer
Dim iColumnNo_Array As Integer
Dim vaEmployeeData As Variant '''the created array
Dim iLastRowNo As Integer
Dim iRowNo As Integer
Dim wks As Worksheet
iColumnNo_Array = 0
Set wks = Worksheets("Sheet1")
With wks
iLastRowNo = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Each vColumnNo_Worksheet In Array(1, 2, 3, 6, 4, 5)
''''''Basic premise If vColumnNo_WorkSheet = 6 Then limit array entries. If they appear in column6 of worksheet ignore them in Column3 of worksheet
iColumnNo_Worksheet = CInt(vColumnNo_Worksheet)
iColumnNo_Array = iColumnNo_Array + 1
If iColumnNo_Array = 1 Then
'''''''''''''''''''''''''''''''''''''''''''''''''''''
ReDim vaEmployeeData(1 To iLastRowNo, 1 To iColumnNo_Array)
Else: ReDim Preserve vaEmployeeData(1 To iLastRowNo, 1 To iColumnNo_Array)
End If
For iRowNo = 1 To iLastRowNo
vaEmployeeData(iRowNo, iColumnNo_Array) = .Cells(iRowNo, iColumnNo_Worksheet).Value
Next iRowNo
Next vColumnNo_Worksheet
End With
mvaEmployeeData = vaEmployeeData
End Function
mvaEmployeeData is array format Variant/Variant (1 to 21, 1 to 6)
And a dummy workbook attached. The yellow area denotes the original limits of the database
In an ideal world the proper solution would be that if entries exceed a specific number a second (overspill) column is created, moving everything across, but that is for another day
Bookmarks