I have an Excel file with a number of connections which can be refreshed. I am trying to build the following macro to a) refresh all connections throughout the workbook, b) add a value to two specific cells on one worksheet, then c) add two formulas which should be applied as far as the last row of data (once the connections have been refreshed):
Sub GetData()
Sheets("AllCallsV3").Cells.Clear
ThisWorkbook.RefreshAll
Worksheets("AllCallsV3").Activate
Range("N1").Value = "Exclude"
Range("O1").Value = "Include"
Sub GetData()
Sheets("AllCallsV3").Cells.Clear
ThisWorkbook.RefreshAll
Worksheets("AllCallsV3").Activate
Range("N1").Value = "Exclude_Stop_Code"
Range("O1").Value = "Include_DX_Code"
Range("N3:N" & LastRow).Formula = "=IF(ISNUMBER(MATCH(F3,Exclusions!$A:$A,0)),1,0)"
Range("O3:O" & LastRow).Formula = "=IF(ISNUMBER(MATCH(I3,Exclusions!$C:$C,0)),1,0)"
End Sub
This returns an error as follows:
ErrorMessage.PNG
If I choose 'End', the connections continue to refresh and the values are inserted into cells N1 and O1 but the formulas are not added.
Any ideas? I'm pretty new to VBA so apologies if I've made some very basic errors!
Bookmarks