Hello everyone I am getting a compile Error: Type Does not match. in the code below. I was hoping you folks can help me out. Thank you!
Private Sub cmbBusId_AfterUpdate()
With Me
.txtStOdo = Application.WorksheetFunction.MaxIfs(Range("DataTable").ListObject.ListColumns("Ending Odometor"), (Range("DataTable").ListObject.ListColumns("Bus ID")), Me.cmbBusId)
End With
End Sub
ListColumns.DataBodyRange
MAXIFS function
(Microsoft) Me
keyword. The worksheet contains a text box and a combo box. The DataTable
(named) range consists of at least one cell contained in the ListObject
(Excel structured table). DataBodyRange
part' of the list columns.ListObject
variable ( tbl
) to make the code more readable.MaxIfs
parameters.Option Explicit
Private Sub cmbBusId_AfterUpdate1()
With Me
Dim tbl As ListObject: Set tbl = .Range("DataTable").ListObject
.txtStodo = Application.WorksheetFunction.MaxIfs( _
tbl.ListColumns("Ending Odometor").DataBodyRange, _
tbl.ListColumns("Bus ID").DataBodyRange, _
.cmbBusId)
End With
End Sub
Private Sub cmbBusId_AfterUpdate2()
With Me
Dim tbl As ListObject: Set tbl = .Range("DataTable").ListObject
Dim mrg As Range ' Max Range
Set mrg = tbl.ListColumns("Ending Odometor").DataBodyRange
Dim crg1 As Range ' Criteria Range 1
Set crg1 = tbl.ListColumns("Bus ID").DataBodyRange
Dim Criteria1 As Double ' Criteria 1
Criteria1 = .cmbBusId
.txtStodo = Application.WorksheetFunction.MaxIfs(mrg, crg1, Criteria1)
End With
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.