I'm getting the error message of
Wrong number of arguments or invalid property assignment
at this line:
Set hello = Range("O" & row, "Q" & row, "W" & row)
However, the macro runs smoothly with Set hello = Range("O" & row). So it means this macro is okay with one cell selection, but getting error with multiple cells selection. I cannot figure out which setting in my macro causes this error. Appreciate your help.
Sub ImportDatafromotherworksheet()
Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim rngSourceRange As Range
Dim rngDestination As Range
Dim row As Integer
Dim hello As Range
Set wkbCrntWorkBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set rngSourceRange = Application.InputBox(Prompt:="Select source row", Title:="Source Range", Default:="press Ctrl for multiple selection", Type:=8)
row = rngSourceRange.row
Set hello = Range("O" & row, "Q" & row, "W" & row)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(Prompt:="Select destination cell", Title:="Select Destination", Default:="A1", Type:=8)
hello.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
End Sub