Hi,
I tried something with the code (marked as bold) but it does not seem to be working can anybody help here to achieve the result, the code is as follows:
Private Sub UserForm_Activate()
'Set some of the properties for the ListView
'Set some of the properties for the ListView
UserForm4.TextBox1.Value = Format(Now(), "dd/mm/yyyy")
UserForm4.Label2 = UserForm4.TextBox1.Value
TextBox2.Text = Sheet7.Cells(1, 3)
UserForm4.Label3 = UserForm4.TextBox2.Value
With Me.ListView1
.Gridlines = True
.HideColumnHeaders = False
.View = lvwReport
.ColumnHeaders.Add , , "Polymer Version", 155
.ColumnHeaders.Add , , "Avilable Quantity (Kg)", 175
.ColumnHeaders.Add , , "Wastage Quantity (Kg)", 175
.ColumnHeaders.Add , , "Cutoff (Kg)", 175
End With
With Me.ListView2
.Gridlines = True
.HideColumnHeaders = False
.View = lvwReport
.ColumnHeaders.Add , , "", 0
.ColumnHeaders.Add , , "", 0
.ColumnHeaders.Add , , "Job Number", 80
.ColumnHeaders.Add , , "Hybrid/ Variety", 100
.ColumnHeaders.Add , , "Batch Number", 80
.ColumnHeaders.Add , , "Quantity of Seeds Coated (Kg)", 160
.ColumnHeaders.Add , , "Polymer Used", 100
End With
'Call the sub to fill the ListView1
Call LoadListView1
'Call the sub to fill the ListView2
Call LoadListView2
End Sub
Private Sub LoadListView1()
'Declare the variables
Dim wksSource As Worksheet
Dim rngData As Range
Dim rngCell As Range
Dim LstItem As ListItem
Dim RowCount As Long
Dim ColCount As Long
Dim i As Long
Dim j As Long
Dim k As Long
'Set the source worksheet
Set wksSource = Worksheets("Stock Pivot")
'Set the source range
Set rngData = wksSource.Range("A6").CurrentRegion
'Count the number of rows in the source range
RowCount = rngData.Rows.Count
'Count the number of columns in the source range
ColCount = rngData.Columns.Count
'Fill the ListView1
For i = 3 To RowCount
Set LstItem = Me.ListView1.ListItems.Add(Text:=rngData(i, 1).Value)
For j = 2 To ColCount
Select Case j
Case 2 To 6
LstItem.ListSubItems.Add Text:=Format(rngData(i, j).Value, "0.00")
Case Else
LstItem.ListSubItems.Add Text:=rngData(i, j).Value
End Select
Next j
Next i
For k = 1 To ColCount
Select Case k
Case 2 To 6
If LstItem.ListSubItems.Add.Text = rngData(1, 2).Value > LstItem.ListSubItems.Add.Text = rngData(1, 4).Value Then
LstItem.ListSubItems.Add.ForeColor = vbRed
Else
LstItem.ListSubItems.Add.ForeColor = vbGreen
End If
End Select
Next k
End Sub
Private Sub LoadListView2()
'Declare the variables
Dim wksSource As Worksheet
Dim rngData As Range
Dim rngCell As Range
Dim LstItem As ListItem
Dim RowCount As Long
Dim ColCount As Long
Dim i As Long
Dim j As Long
'Set the source worksheet
Set wksSource = Worksheets("Coating Status")
'Set the source range
Set rngData = wksSource.Range("A2").CurrentRegion
'Count the number of rows in the source range
RowCount = rngData.Rows.Count
'Count the number of columns in the source range
ColCount = rngData.Columns.Count
'Fill the ListView2
For i = 3 To RowCount
Set LstItem = Me.ListView2.ListItems.Add(Text:=rngData(i, 1).Value)
For j = 2 To ColCount
Select Case j
Case 6 To 7
LstItem.ListSubItems.Add Text:=Format(rngData(i, j).Value, "0.00")
Case Else
LstItem.ListSubItems.Add Text:=rngData(i, j).Value
End Select
Next j
Next i
End Sub