Hi, until recently my piece of code worked, ran once each week, but now no longer works due to a compile error. I'm using Excel 2010 and had a load of updates recently.
routine falls over at the fname variable. (shown in red)
Cell K1 holds the date and has 'dd-mmm' custom format so appears as '30-Oct'
routine falls over at the fname variable. (shown in red)
Cell K1 holds the date and has 'dd-mmm' custom format so appears as '30-Oct'
Code:
Dim Fname As String
Dim Ans As Integer
Dim Title As String
Dim Config1 As Integer
Dim Config2 As Integer
Dim thisWb As Workbook
Set thisWb = ActiveWorkbook
Fname = Sheets("Master").Range("k1").Text
Config1 = vbYesNo + vbDefaultButton2 + vbQuestion
Config2 = vbOKOnly + vbInformation
Title = "Weekly Process"
Ans = MsgBox("Have you copied over the latest data?", Config1, Title)
Select Case Ans
Case vbYes
Columns("A:N").Copy
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=thisWb.Path & "\Weekly data week ending " & Fname
ActiveWindow.DisplayGridlines = False
Windows("Data Master for Week Ending files.xlsm").Activate
Columns("A:N").Select
Selection.Copy
Windows("Weekly data week ending " & [COLOR=#ff0000]Fname)[/color].Activate
Range("A1").Select
ActiveSheet.Paste
Columns("D:N").Copy
Range("D1").PasteSpecial Paste:=xlPasteValues