Fejl i VBA
Hej alle Excel hjælpere.Jeg bruger nedenstående VBA kode, til at flytte 4 linier, og sætte dem ind i det ark jeg har VBA koden liggende i.
Men jeg for en fejl i linjen rngSourceRange.Copy rngDestination
Kan nogle hjælpen. Oploader lige filerne hvis det kan lette hjælpen.
https://1drv.ms/u/s!AmLaaGiC5LdohuMNbZipXizBzdsLKA?e=NHVUwA
Private Sub CommandButton1_Click()
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
.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:="b5:e5;b8:e8;b11:e11;b14:e14", Type:=8)
wkbCrntWorkBook.Activate
Set rngDestination = Application.InputBox(prompt:="Select destination cell", Title:="Select Destination", Default:="b4:e4;b7:e7;b10:e10;b13:e13", Type:=8)
rngSourceRange.Copy rngDestination
rngDestination.CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
End Sub
