'Why does my excel spreadsheet freezes when it finishes running the VBA code for copy & paste data from another workbook in next row available?
I have this code to browse files from another workbook (named: "quote") After copying the data I paste it into the ("budget" workbook) on sheet1 (named: "data") When I click the "Import quote" button, and it finishes copy & paste the data on the next available row, the spreadsheet freezes and I´m not allowed to click on any cell nor button. Only when I minimize the workbook and enlarge it again it works. I want.
Why does my excel spreadsheet freezes when it finishes running the following code? :
Sub Get_Data_From_File()
Dim FiletoOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FiletoOpen = Application.GetOpenFilename(Title:="Browse your File & Import Range", Filefilter:="Excel Files (*.xls*),*xls*")
If FiletoOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FiletoOpen)
OpenBook.Sheets(2).Range("A2:i2").Copy
'---------------------------------------------------------
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("DATA")
Dim nextRow As Integer
nextRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1
If nextRow = 0 Then nextRow = 1
'--------------------------------------------------------
ws.Range("A" & nextRow).PasteSpecial xlPasteValues
OpenBook.Close False
Sheets(1).Range("A" & nextRow).Select
'ThisWorkbook.Worksheets("DATA").Range("A6:i6").PasteSpecial xlPasteValues
'OpenBook.Close False
End If
Application.ScreenUpdating = True
End Sub
THANK YOU VERY MUCH!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
