Excel VBA将特定单元格复制并粘贴到另一张图纸上
我想看看某个特定的单元格是否是我期望的值,如果是,我想将其粘贴到另一张图纸上。但我的代码不知怎么出了问题。 这是我的密码:Excel VBA将特定单元格复制并粘贴到另一张图纸上,excel,vba,Excel,Vba,我想看看某个特定的单元格是否是我期望的值,如果是,我想将其粘贴到另一张图纸上。但我的代码不知怎么出了问题。 这是我的密码: Private Sub CommandButton1_Click() Sheets("Sheet3").Select If Cells(2,6).Value == 25 Then Cells(2, 6).Select Selection.Copy Sheets("Sheet1").Select
Private Sub CommandButton1_Click()
Sheets("Sheet3").Select
If Cells(2,6).Value == 25 Then
Cells(2, 6).Select
Selection.Copy
Sheets("Sheet1").Select
Cells(4, 1).Paste
End If
End Sub
VBA使用单个=符号进行比较
Private Sub CommandButton1_Click()
If workSheets("Sheet3").Cells(2,6).Value = 25 Then
workSheets("Sheet1").Cells(4, 1) = 25
End If
End Sub
您可以编写一个交互式窗口来输入可能更改的值
Private Sub CommandButton1_Click()
Dim exp_val As Integer
exp_val = InputBox("What's the value you expect?")
If Worksheets("Sheet3").Cells(2, 6).Value = exp_val Then
Worksheets("Sheet2").Cells(4, 1).Value = exp_val
End If
End Sub
Private Sub CommandButton1_Click()
Dim exp_val As Integer
exp_val = InputBox("What's the value you expect?")
If Worksheets("Sheet3").Cells(2, 6).Value = exp_val Then
Worksheets("Sheet2").Cells(4, 1).Value = exp_val
End If
End Sub