Hi everybody,
I'm still trying to wrap my head around the idea of 'early' and 'late' binding and I couldn't understand it. I've looked up on google but I don't know how to apply to my code.
Basically, I started looking for solutions when I created a shared file but people using different versions of excel. Some people has Microsoft Office 15.0 Object Library while others have Microsoft Office 16.0 Object library. A 'compiling error' often occurs for some when trying to run the program.
I heard 'late binding' can resolve the situation but I don't know how to apply it to my code:
My code is something like this:
How do apply late binding to my code?
I'm still trying to wrap my head around the idea of 'early' and 'late' binding and I couldn't understand it. I've looked up on google but I don't know how to apply to my code.
Basically, I started looking for solutions when I created a shared file but people using different versions of excel. Some people has Microsoft Office 15.0 Object Library while others have Microsoft Office 16.0 Object library. A 'compiling error' often occurs for some when trying to run the program.
I heard 'late binding' can resolve the situation but I don't know how to apply it to my code:
My code is something like this:
Code:
Dim sheet1 As Worksheet
Set sheet1 = Sheets("Data")
Dim sheet2 As Worksheet
Set sheet2 = Sheets("Stats")
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim start_row As Integer
Dim end_row As Integer
Dim start_col As Integer
Dim end_col As Integer
start_row = 2
end_row = 46
start_col = 10
end_col = 37
start_col_CE = 39
end_col_CE = 45
For i = start_row To end_row
For j = start_col To end_col Step 4
If sheet1.Cells(i, j) <> "" And sheet1.Cells(i, j) < sheet1.Range("A48") Then
'some function here
If sheet1.Cells(i, 46) <> 0 Then
For k = start_col_CE To end_col_CE
If sheet1.Cells(i, k) = "" Then
empty_col_CE = k
Exit For
End If
Next k
CE_date = CDate(sheet1.Cells(i, j))
CE_month = Month(CE_date)
CE_month_row = CE_month + 1
'some function here
sheet2.Cells(CE_month_row, CE_type_col) = sheet2.Cells(CE_month_row, CE_type_col) + 1
sheet1.Cells(i, empty_col_CE) = CE_type & CE_date & " : " & sheet1.Cells(i, j + 2)
sheet1.Range(Cells(i, j), Cells(i, j + 3)) = ""
ElseIf sheet1.Cells(i, 46) = 0 Then
For l = start_col_CE To end_col_CE - 1
sheet1.Cells(i, l) = sheet1.Cells(i, l + 1)
Next l
CE_date = CDate(sheet1.Cells(i, j))
CE_month = Month(CE_date)
CE_month_row = CE_month + 1
'Some function here
sheet2.Cells(CE_month_row, CE_type_col) = sheet2.Cells(CE_month_row, CE_type_col) + 1
sheet1.Cells(i, end_col_CE) = CE_type & CE_date & " : " & sheet1.Cells(i, j + 2)
sheet1.Range(Cells(i, j), Cells(i, j + 3)) = ""
End If
End If
Next j
Next i
How do apply late binding to my code?
Last edited: