从内部单元格中拾取值以进行循环VBA

时间:2017-01-20 20:30:31

标签: excel-vba excel-2016 vba excel

Sub asd()

a = 34

For x = 1 To 4

**prev = Sheets("Sheet1").Cells(1, x - 1).Value**
this = Sheets("Sheet1").Cells(1, x).Value
**nex = Sheets("Sheet1").Cells(1, x + 1).Value**

If WorksheetFunction.Median(prev, this, nex) = a Then
    MsgBox (x)
Else
End If
Next
End Sub

为什么粗体行不起作用。我也试过

prevnum = x-1
prev = Sheets("Sheet1").Cells(1, prevnum).Value

但它不起作用。

0 个答案:

没有答案