Hi! I need your help to understand why my macro is not working whenever I open a SharePoint file. Note that the SharePoint is synced in my laptop and and when I run my macro, my SharePoint file is open as Read Only.
Below is may code:
Sub FormatFiles()
Dim ws As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Name1 = ActiveWorkbook.Name
Path1 = "C:\Users" & RB1 & "\KNIME_DEPLOYMENT\workspace\Gross Contribution\02 INPUT FILES"
'Working File
Filename1 = "Asia_HQ_FA_Reporting_Deck" & ".xlsm"
Workbooks.Open Filename:=Path1 & Filename1
Workbooks("Asia_HQ_FA_Reporting_Deck.xlsm").Activate
For Each ws In ActiveWorkbook.Worksheets
If Left(ws.Name, 18) = "Country Financials" Then
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="N/A", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="#DIV/0!", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("L9:AZ73").Select
Selection.Replace What:="MM", Replacement:="000000", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("L9:AZ73").Select
Selection.Replace What:="$", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
Next
ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox "Formatting is complete. Please open your KNIME WORKFLOW."
End Sub
Below is may code:
Sub FormatFiles()
Dim ws As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Name1 = ActiveWorkbook.Name
Path1 = "C:\Users" & RB1 & "\KNIME_DEPLOYMENT\workspace\Gross Contribution\02 INPUT FILES"
'Working File
Filename1 = "Asia_HQ_FA_Reporting_Deck" & ".xlsm"
Workbooks.Open Filename:=Path1 & Filename1
Workbooks("Asia_HQ_FA_Reporting_Deck.xlsm").Activate
For Each ws In ActiveWorkbook.Worksheets
If Left(ws.Name, 18) = "Country Financials" Then
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Replace What:="N/A", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="#DIV/0!", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="#REF!", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("L9:AZ73").Select
Selection.Replace What:="MM", Replacement:="000000", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("L9:AZ73").Select
Selection.Replace What:="$", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
Next
ActiveWorkbook.Save
ActiveWorkbook.Close
MsgBox "Formatting is complete. Please open your KNIME WORKFLOW."
End Sub