0

I am trying to get VBA to run the following code- this seems to be working for some people and not for others and after reading a ton of blogs I am stumped- because it WAS working for everyone so I don't know what changed. Essentially they are hitting a button within an Excel workbook to move certain data from their sheet to a master file- the debug is highlighting the bottom portion of the code ActiveWorkbook.Save.... any ideas on what could be going wrong?

Sub BulkUpload()

    Dim LN, Match As Integer
    Dim wb As Workbook
    Dim Name As String
    Name = "path goes here"

    Application.ScreenUpdating = False

    Sheets("LADB Bulk Upload").Select
    LN = Range("A2").Value



    Range("A2:HH2").Copy


    Set wb = Workbooks.Open(Filename:=Name)
    If IsError(Application.Match(LN, ActiveSheet.Range("A:A"), 0)) Then

        Range("A100000").End(xlUp).Select
        ActiveCell.Offset(1, 0).Select

        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False

    Else

        Match = Application.Match(LN, wb.Sheets("Sheet1").Range("A:A"), 0)

        Cells(Match, 1).Select

        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False

    End If

    Application.CutCopyMode = False

    **ActiveWorkbook.Save**
    ActiveWorkbook.Close

    Application.ScreenUpdating = True

End Sub
Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
  • What is the error message you get? This could be important when determining what issue you have. One of the issues you might have is that the file might be temporary unavailable as it's being used by another user for example. – Plutian Jan 20 '20 at 13:07
  • Also please note that using `activesheet` and `activeworkbook` is prone to errors. Since you dim the workbook as "wb" it's better to use that and specify the sheet name. You will also benefit from reading [this](https://stackoverflow.com/a/10717999/11936678). – Plutian Jan 20 '20 at 13:10
  • Users are getting an error that the specified sheet already exists- it's the "activeWorkbook.Save" that is having the error – CaitlinMc1115 Jan 20 '20 at 13:31

0 Answers0