i have three dynamic columns that have dates in them.
there are dates in column E, I, and J starting at row 5 and going down X number of rows...X because i have an external feed which updates and it results in column E, I and J going down different numbers of rows every time it updates....but each column will have data going down to the same row for each update.... i would like to populate cells M5:MX with the difference in days between colE - colI and cells N5:NX with the difference in days between colJ - colE
im getting a "Run-time error 13" "Type mismatch"
im new to vba so im not sure how to fix this error
the update also populates data in column B, from cell B5:BX, it will also go down the same number of rows as column E, I, and J
the variable RowCount determines how many rows starting at row 5 have data in them....
this is in worksheet2 so im using the worksheet change event handler...
here is what the code looks like
any input will be greatly appreciated
there are dates in column E, I, and J starting at row 5 and going down X number of rows...X because i have an external feed which updates and it results in column E, I and J going down different numbers of rows every time it updates....but each column will have data going down to the same row for each update.... i would like to populate cells M5:MX with the difference in days between colE - colI and cells N5:NX with the difference in days between colJ - colE
im getting a "Run-time error 13" "Type mismatch"
im new to vba so im not sure how to fix this error
the update also populates data in column B, from cell B5:BX, it will also go down the same number of rows as column E, I, and J
the variable RowCount determines how many rows starting at row 5 have data in them....
this is in worksheet2 so im using the worksheet change event handler...
here is what the code looks like
any input will be greatly appreciated
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim RowCount As Double
RowCount = Application.WorksheetFunction.CountA(Range("B5:B200"))
Dim Counter2 As Double
Counter = 0
Application.EnableEvents = False
Do Until Counter2 > RowCount - 1
Range("M5").Offset(Counter2, 0) = (Range("M5").Offset(Counter2, -8)) - (Range("M5").Offset(Counter2, -4))
Range("N5").Offset(Counter2, 0) = (Range("N5").Offset(Counter2, -4)) - (Range("N5").Offset(Counter2, -9))
Counter2 = Counter2 + 1
Loop
Application.EnableEvents = True
End Sub