【发布时间】:2014-05-12 17:25:11
【问题描述】:
目前我正在制作一个需要执行以下操作的宏。
1) 它查看顶行,返回一个命名列
2) 然后选择此列
3) 然后循环遍历列,寻找第一个大于零的值。
4) 然后我取这个“第一个”实例的行值
5) 从我的公共变量中,我得到一个列值(#'s)
6)我结合行值和列值来找到我的“数据点”
最后,我想将此值复制到同一工作簿中名为“关键信号”的另一个工作表中
这就是我遇到麻烦的地方。每次我运行我的代码时,我都会收到错误“1004”。我似乎无法将选定的单元格复制并粘贴到我的第二个工作表中。有任何想法吗?
Sub Locate_Start_Of_Test()
'Use the Find Method to identify signal columns
Dim SigCol As Integer
Dim SigRow As Integer
Dim Cell As Range
Dim CritRow As Integer
'Variables to hold critical point of Start of Test
SigRow = 1 'Row Location of Signal Names
SigCol = Sheet1.Cells(SigRow, 1).EntireRow.Find(What:="EngAout_N_Actl (rpm)", LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Column
'SigCol now holds the value of rpm column
Columns(SigCol).Select
CritRow = 1
For Each Cell In Selection
If Cell.Value > 0 And Cell.Value <> "EngAout_N_Actl (rpm)" Then
Exit For
End If
CritRow = CritRow + 1
Next Cell
Sheets(1).Range(Cells(CritRow, Trip_point)).Copy
Sheets("Critical Signals").Activate
Range("E4").Select
ActiveSheet.Paste
End Sub
【问题讨论】:
标签: vba excel copy-paste