需要VBA从单元格而不是VBA中的文本中获取值

时间:2014-08-12 21:06:49

标签: excel vba excel-vba

我需要这个VBA而不是仅仅在单元格中放置值“X”来从工作簿中的单元格中获取文本。工作表“订单输入”中的单元格为B4。谢谢。

Sub Check()
    Dim dat As Variant
    Dim rng As Range
    Dim i As Long

    Set rng = Sheets("Customer List").Range("D2:D100")
    dat = rng.Value
    For i = LBound(dat, 1) To UBound(dat, 1)
        If dat(i, 1) <> "" Then
            rng(i, -2).Value = "X"
        End If
    Next
End Sub

1 个答案:

答案 0 :(得分:0)

Sub Check()
Dim dat As Variant
Dim rng As Range
Dim i As Long

Set rng = Sheets("Customer List").Range("D2:D100")
dat = rng.Value
For i = LBound(dat, 1) To UBound(dat, 1)
    If dat(i, 1) <> "" Then
        rng(i, -2).Value = ThisWorkBook.Sheets("Order Entry").Range("B4").Value
    End If
Next
End Sub