Copy a column selected by input box to the next available column on an existing sheet

sungirl2215

New Member
Joined
Jul 14, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Very new to VAB and I have a workbook with both values and free text survey responses. I'm trying to cut the Free Response Text columns to their own sheet in my workbook. The columns this free text will be in may vary depending on the survey data entered, so I've used the input box to allow the user to select the correct column to be copied.

I understand how to paste that data into specific columns in the new sheet, but this code may be run several times if there are multiple free text columns.

How can I adjust my code to paste to the next available column of the designated sheet? Giving the option to select multiple, non-consecutive columns at once would also work.

VBA Code:
Sub CopyFreeText()
    
    Dim MySelection As Range
    
    On Error Resume Next
    Set MySelection = Application.InputBox("Select the column to move.", "Move Column", Type:=8)
    If MySelection Is Nothing Then Exit Sub 'user canceled
    On Error GoTo 0
    
    MySelection.EntireColumn.Cut (Sheets("Free Text Response").Range("A:A"))
    Application.CutCopyMode = False
    
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top