Hi,
I have some VBA code that I have been using successfully on a file, but now have moved to storing this file on a SharePoint.
Now I'm getting a Compile Error ; Type Mismatch with the first line of the code (the BeforeSave) highlighted.
Does anyone know what I should change this to?
I want the VBA to run at the same point (when someone saves the file) but to play nicely with SharePoint.
Here is my code:
I have some VBA code that I have been using successfully on a file, but now have moved to storing this file on a SharePoint.
Now I'm getting a Compile Error ; Type Mismatch with the first line of the code (the BeforeSave) highlighted.
Does anyone know what I should change this to?
I want the VBA to run at the same point (when someone saves the file) but to play nicely with SharePoint.
Here is my code:
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'
' Archive notes when something new is available
'
Dim i As Long
Dim ii As Long
Dim LastRow As Long
Dim wd As Workbook
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Set wb = ThisWorkbook
Set sht1 = wb.Sheets("Tracker")
Set sht2 = wb.Sheets("archive")
LastRow = 50
ii = 2
Application.Screenupdating = False
For i = 6 To LastRow
If IsEmpty(sht1.Range("O" & i)) Then
Else
sht2.Range("B" & ii) = sht1.Range("N" & i) & Chr(10) & sht2.Range("B" & ii)
sht1.Range("N" & i) = DateTime & " " & sht1.Range("O" & i)
sht1.Range("O" & i).Clear
End If
ii = ii + 1
Next i
Application.Screenupdating = True
End Sub