imelquilolo
New Member
- Joined
- Dec 29, 2024
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi, newbie here.
I have a code that allows me to copy values in specific cells of a workbook to another open workbook that reference the filename in cell J58. The code work as intended and copy values to the other workbook. While I was editing the message box and used Step Into(F8), after this line "Workbooks(Outsource).Sheets("DOL").Range("H22:I22").PasteSpecial Paste:=xlPasteValues", all opened excel files will force closed and open again.
Please educate me what happened and how to refine the code to avoid force closed.
I have not yet tried to used another pc/laptop.
Happy Holidays!
I have a code that allows me to copy values in specific cells of a workbook to another open workbook that reference the filename in cell J58. The code work as intended and copy values to the other workbook. While I was editing the message box and used Step Into(F8), after this line "Workbooks(Outsource).Sheets("DOL").Range("H22:I22").PasteSpecial Paste:=xlPasteValues", all opened excel files will force closed and open again.
Please educate me what happened and how to refine the code to avoid force closed.
I have not yet tried to used another pc/laptop.
Code:
Sub Macro1()
' Macro1 Macro
Dim Answer As VbMsgBoxResult
Dim Outsource As String
Outsource = ThisWorkbook.ActiveSheet.Range("J58").Value
Answer = MsgBox("Please make sure to input the correct Filename and extension of DOL_PRO at Cell J58. Are you sure you want to proceed?", vbYesNo)
If Answer = vbYes Then
Application.ScreenUpdating = False
ThisWorkbook.ActiveSheet.Range("K62:L62").Copy
' Force close after I Step Into(F8) the line below
Workbooks(Outsource).Sheets("DOL").Range("H22:I22").PasteSpecial Paste:=xlPasteValues
ThisWorkbook.ActiveSheet.Range("K63:L63").Copy
Workbooks(Outsource).Sheets("DOL").Range("N22:O22").PasteSpecial Paste:=xlPasteValues
ThisWorkbook.ActiveSheet.Range("K64:L64").Copy
Workbooks(Outsource).Sheets("DOL").Range("T22:U22").PasteSpecial Paste:=xlPasteValues
ThisWorkbook.ActiveSheet.Range("O62:P62").Copy
Workbooks(Outsource).Sheets("DOL").Range("X22:Y22").PasteSpecial Paste:=xlPasteValues
ThisWorkbook.ActiveSheet.Range("O63:P63").Copy
Workbooks(Outsource).Sheets("DOL").Range("Z22:AA22").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
End Sub
Happy Holidays!