当我运行第一组代码时,代码可以工作...
Sheets("Pricing Request").Range("C8:D8").Value = Sheets("User Interface").Range(Cells(rowIndex, 22), Cells(rowIndex, 23)).Value
Sheets("Pricing Request").Range("E8:E8").Value = Sheets("User Interface").Range(Cells(rowIndex, 26), Cells(rowIndex, 26)).Value
但是当我碰到单元格引用的范围时,它不起作用..
Sheets("Pricing Request").Range(Cells(8, 3), Cells(8, 4)).Value = Sheets("User Interface").Range(Cells(rowIndex, 22), Cells(rowIndex, 23)).Value
Sheets("Pricing Request").Range(Cells(8, 5), Cells(8, 5)).Value = Sheets("User Interface").Range(Cells(rowIndex, 26), Cells(rowIndex, 26)).Value
这是我要使用的代码,但是上面的代码是我试图解决的问题...
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rowIndex As Integer
Dim nextEmpty As Integer
rowIndex = ActiveCell.row
nextEmpty = Sheets("Pricing Request").Range("Q1:Q1").Value
Sheets("Pricing Request").Range(Cells(nextEmpty, 3), Cells(nextEmpty, 4)) = Sheets("User Interface").Range(Cells(rowIndex, 22), Cells(rowIndex, 23)).Value
Sheets("Pricing Request").Range(Cells(nextEmpty, 5), Cells(nextEmpty, 5)) = Sheets("User Interface").Range(Cells(rowIndex, 26), Cells(rowIndex, 26)).Value
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rowIndex As Integer
Dim nextEmpty As Integer
rowIndex = ActiveCell.row
nextEmpty = Sheets("Pricing Request").Range("Q1:Q1").Value
Sheets("Pricing Request").Range(Cells(nextEmpty, 3), Cells(nextEmpty, 4)) = Sheets("User Interface").Range(Cells(rowIndex, 22), Cells(rowIndex, 23)).Value
Sheets("Pricing Request").Range(Cells(nextEmpty, 5), Cells(nextEmpty, 5)) = Sheets("User Interface").Range(Cells(rowIndex, 26), Cells(rowIndex, 26)).Value
我希望能够在双击单元格时将值复制到活动工作表上并将其粘贴到另一个非活动工作表上。复制的数据范围与双击单元格所在的行相关联