Results 1 to 2 of 2

Delete array elements from 1 column if they appear in another column. Both column in array

Threaded View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Delete array elements from 1 column if they appear in another column. Both column in array

    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
    Attached Files Attached Files
    Last edited by nigelog; 04-04-2019 at 12:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Function to delete a selected Row/Column in an array
    By LeoDan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2016, 06:08 PM
  2. Replies: 3
    Last Post: 03-07-2016, 09:54 PM
  3. Replies: 5
    Last Post: 11-24-2015, 08:15 AM
  4. [SOLVED] 2 Column Lookup with 6 Column array Col index number is Varies Within Entire Array
    By Weasyb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-05-2015, 12:54 PM
  5. Replies: 0
    Last Post: 01-14-2014, 06:35 PM
  6. Delete row if value(array) doesnt exist in column
    By wobaby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2009, 02:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1