I would like to create an user-defined
function in Excel
that can return the current worksheet. I could use the
sheetname = Activ
i need to change the sheet name by the name of the file was opened
Sub Get_Data_From_File5()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Dim currentName As String
currentName = ActiveSheet.Name
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.csv*),*csv*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets(1).Range("A1:g5000").Copy
ThisWorkbook.Worksheets(currentName).Range("Aw1:bc5000").PasteSpecial xlPasteValues
OpenBook.Close False
End If
Application.ScreenUpdating = True
End Sub