Hey everyone!
I'm new to VBA and have been attempting to achieve the following:
1. Message prompt let's the user select a cell from the column that is to be copied. Based on that cell, the entire column is copied.
2. The user then selects a cell from the column to which the copied column should be pasted. Here I don't want to overwrite any preexisting data and instead want the copied column to be pasted to the end of this column.
The code looks like this:
I highlighted the line of code that I'm not getting to work as planned (in this current version, nothing is pasted). Any ideas? Help would be very much appreciated.
I'm new to VBA and have been attempting to achieve the following:
1. Message prompt let's the user select a cell from the column that is to be copied. Based on that cell, the entire column is copied.
2. The user then selects a cell from the column to which the copied column should be pasted. Here I don't want to overwrite any preexisting data and instead want the copied column to be pasted to the end of this column.
The code looks like this:
VBA Code:
Sub test2()
Set ws1 = Sheets("Test Sheet 1")
Set ws2 = Sheets("Test Sheet 2")
Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox(Prompt:="Select a cell from the column that is to be copied .", Title:="Select Column", Type:=8)
On Error GoTo 0
If rng Is Nothing Then Exit Sub
Dim rng2 As Range
On Error Resume Next
Set rng2 = Application.InputBox(Prompt:="Select a cell from the column in which the data should be pasted", Title:="Select column", Type:=8)
Columns(rng.Column).Copy
[COLOR=rgb(251, 160, 38)] ws2.Range(rng2.Columns & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues[/COLOR]
Application.CutCopyMode = False
End Sub
I highlighted the line of code that I'm not getting to work as planned (in this current version, nothing is pasted). Any ideas? Help would be very much appreciated.