开发者

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

开发者 https://www.devze.com 2022-12-07 22:16 出处:网络
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

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.

'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.Co开发者_运维技巧py

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

精彩评论

暂无评论...
验证码 换一张
取 消