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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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