Hi Everyone,
I have the following macro which works well except for one issue. It will import a selected file to whichever sheet is open at the time and I need to edit it where it imports to a sheet titled "POS IMPORT" whether its open or not.
Thanks in advance!!
I have the following macro which works well except for one issue. It will import a selected file to whichever sheet is open at the time and I need to edit it where it imports to a sheet titled "POS IMPORT" whether its open or not.
Thanks in advance!!
Code:
Sub ImportDatafromotherworksheet() Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range
Set wkbCrntWorkBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa; *.csv;"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set rngSourceRange = Application.InputBox(prompt:="Select source range", Title:="Source Range", Default:="A1", Type:=8)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
End Sub