pop up message all of data contain date when open file

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
240
Office Version
  1. 2019
  2. 2010
hi
I search for macro when open file . it pop up message show all of data based on col M contains date
so in my case it should show the rows 2,6,10

REP1.xlsm
ABCDEFGHIJKLM
1ITEMBATCH NOCODE NONAMEAMOUNTNOTESDATE
21BT-00CD-00ALI1250RECORDED03/08/2021
32BT-01CD-01ALI2200NOT RECORDED
43BT-02CD-02ALI3300NOT RECORDED
54BT-03CD-03ALI4400NOT RECORDED
65BT-04CD-04ALI5500RECORDED05/08/2021
76BT-05CD-05ALI6120NOT RECORDED
87BT-06CD-06ALI7300NOT RECORDED
98BT-07CD-07ALI8120NOT RECORDED
109BT-08CD-08ALI950RECORDED07/08/2021
1110BT-09CD-09ALI10120NOT RECORDED
1

the messgae should be like this
ITEMBATCH NOCODE NONAMEAMOUNTNOTESDATE
1BT-00CD-00ALI1250RECORDED
03/08/2021​
2BT-04CD-04ALI5500RECORDED
05/08/2021​
3BT-08CD-08ALI950RECORDED
07/08/2021​
 
then debug and step through the code until you get the error

@Crystalyzer sorry I don't read wll and i fixed it and works well but when I change the date in col L it doesn't show in listbox despite of it I change theses
VBA Code:
With ws
        lRow = .Cells(.Rows.Count, "L").End(xlUp).Row
        arr2Rows = WorksheetFunction.CountA(.Range("L:L"))
        arr = .Range("A1:L" & lRow)
but not succeddes . can you guide me what I have to change, please ?
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
so your data now looks like this?

Mussa 20210807.xlsm
ABCDEFGHIJKLM
1ITEMBATCH NOCODE NONAMEAMOUNTNOTESDATE
21BT-00CD-00ALI1250RECORDED8/3/2021
32BT-01CD-01ALI2200NOT RECORDED
43BT-02CD-02ALI3300NOT RECORDED8/6/2021
54BT-03CD-03ALI4400NOT RECORDED
65BT-04CD-04ALI5500RECORDED8/5/2021
76BT-05CD-05ALI6120NOT RECORDED5/1/2021
87BT-06CD-06ALI7300NOT RECORDED
98BT-07CD-07ALI8120NOT RECORDED
109BT-08CD-08ALI950RECORDED8/7/2021
1110BT-09CD-09ALI10120NOT RECORDED
12
Sheet1
 
Upvote 0
VBA Code:
Private Sub CommandButton1_Click()
    Unload Me
End Sub

Private Sub UserForm_Initialize()
    Load UserForm1
    With ListBox1
        .ColumnCount = 13
        .ColumnWidths = "1 cm;2 cm;2 cm;2 cm;2 cm;3 cm;0;0;0;0;0;3 cm;0"
        .List = ShowDateData()
        .ListIndex = 0
    End With
    With UserForm1
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
    End With
End Sub

Private Function ShowDateData() As Variant
    Dim arr() As Variant
    Dim arr2() As Variant
    Dim lRow As Long, i As Long, j As Long, k As Long, arr2Rows As Long
    Dim ws As Worksheet
    
    Set ws = ActiveSheet
    k = 0
    
    With ws
        lRow = .Cells(.Rows.Count, "L").End(xlUp).Row
        arr2Rows = WorksheetFunction.CountA(.Range("L:L"))
        arr = .Range("A1:L" & lRow)
        ReDim arr2(arr2Rows - 1, UBound(arr, 2) - 1)
        For i = 1 To UBound(arr, 1)
            If arr(i, UBound(arr, 2)) <> "" Then
                For j = 0 To UBound(arr, 2) - 1
                    arr2(k, j) = arr(i, j + 1)
                Next
                k = k + 1
            End If
        Next i
    End With
        
    ShowDateData = arr2
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top