Hi, I am very new to VBA. I need a help on converting the VB code to VBA code. In vb, I am filtering a datagrid view to highlight the cells if the cells contain the time greater than 3:30 and less than 20:00.I have attached a excel file for which the code should reflect. And also I have pasted the code used in vb to highlight the cells in datagridview.Please remember the code below works for any number of records in the datagrid view.E.g. Today there might be 10 rows and 10 columns in a datagrid while tomorrow there might be 12 rows or 12 columns in datagrid - To keep it simple it should work for any number of rows and columns rather than being fixed .
Please help me in providing a new VBA code or converting the below vb code to vba.
Dim colCount as Integer = DGV.Columns.Count
If colCount > 1 Then
Dim startDate As Date = Date.ToDay.Add(New TimeSpan(3, 30, 0))
Dim endDate As Date = Date.ToDay.Add(New TimeSpan(20, 0, 0))
Dim cellValue As String, cellDate As Date
For i As Integer = 1 To colCount - 1
For Each row As DataGridViewRow In DGV.Rows
cellValue = row.Cells(i).Value.ToString
If Date.TryParse(cellValue, cellDate) Then
If cellDate > startDate AndAlso cellDate < endDate Then
row.Cells(i).Style.BackColor = Color.LightYellow