Have user select which column to paste to instead of defined offset

Knockoutpie

Board Regular
Joined
Sep 10, 2018
Messages
116
Office Version
  1. 365
Platform
  1. Windows
This code searches for a column with "CPN" moves down two cells, copies the data, searches the selected data in another sheet, offsets to a defined sell, copies that data and returns to the original sheet.

My issue is, the row I am pasting the data into will sometimes change.. is there a way to have the user select the row that we are pasting into?

At the bottom of the code, you can see where I have offset 6 columns to the right to paste. I want the user to be able to select "Z" or something like that for example.

VBA Code:
'Find CPN
Cells.Find(What:="CPN").Offset(2, 0).Select

'Copy/search

    Dim str1 As String
    Dim Cntr As Integer
    Cntr = 0
    Do While Cntr <= 650

      Cntr = Cntr + 1
      str1 = ActiveCell.Value
      Selection.Copy

      Worksheets("Export").Activate
      ActiveCell.Select
      Cells.Find(What:=str1, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
      Cells.FindNext(After:=ActiveCell).Activate
      ActiveCell.Offset(0, 15).Range("A1").Select
      Selection.Copy

      Worksheets("Quote").Activate
      
      ' Now find Part number and paste into price column
      ActiveCell.Offset(0, 6).Select
      Selection.PasteSpecial Paste:=xlPasteValues
    Loop
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You want user to select "Z" ?
How about this ?
VBA Code:
    Dim myRange As Range
    Set myRange = Application.InputBox("Select a cell to paste.", , , , , , , 8)
    MsgBox myRange.Address
 
Upvote 0
Solution

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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