finAnalysis
New Member
- Joined
- Oct 13, 2021
- Messages
- 12
- Office Version
- 365
- Platform
- Windows
This code selects the range to copy from, and then attempts to insert the copied cells into a new defined range. I am having issues with the code and getting errors. Any help is appreciated.
VBA Code:
Sub Rom_Copy()
Dim Rom_Copy As Variant
Dim CopyFromRange As Range
Dim PasteToRange As Range
MsgBox ("Select ROM")
Rom_Copy = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*")
If Rom_Copy <> False Then
ActiveWorkbook.ActiveSheet.Select
'Will not pick specific sheet, will need to do it myself when range is selected'
On Error Resume Next
Set CopyFromRange = Application.InputBox(Prompt:="Select a range to copy from", Title:="Range Selection", Default:=ActiveCell.Address, Type:=8)
If CopyFromRange Is Nothing Then Exit Sub
On Error GoTo 0
On Error Resume Next
Set PasteToRange = Application.InputBox(Prompt:="Select a range to paste to", Title:="Range Selection", Default:=ActiveCell.Address, Type:=8)
If PasteToRange Is Nothing Then Exit Sub
On Error GoTo 0
CopyFromRange.Copy
Selection.Insert Shift:=xlDown
PasteToRange.Cells(1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End Sub