首页 > 解决方案 > vb.net 做而 excel 单元格值不是“测试值”

问题描述

我是一个新的 VB.net 用户(完全自学)。

我正在尝试向下搜索 excel 工作簿的 A 列(从“A1”开始)以检查单元格内容。在找到一个特定值时,我想用 msgbox 输出它所在的单元格。

任何人都可以帮助我如何编码。

标签: vb.netdo-while

解决方案


玩了一天的各种东西,终于搞定了!!!

我是如何做到的 - 现在我已经解决了它看起来很简单:

    Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet

    ' For the first sheet in an excel workbook
    xlWorkSheet = CType(objApp.Sheets(1), Microsoft.Office.Interop.Excel.Worksheet)
    Dim strSheetName As String = xlWorkSheet.Name

    ' ***** Find the row with "Ambient Temp (C)" as its header
    AmbientRange = objAppDeckCalc.Worksheets(strSheetName).Range("a1")
    TempValue = AmbientRange.Value

    Do While TempValue <> "Ambient Temp (C)"
        AmbientRange = AmbientRange.Offset(1, 0)

        TempValue = AmbientRange.Value

        CountRow = CountRow + 1
        If CountRow = 100 Then
            MsgBox("Fields Not Named Correctly!")
            End
        End If
    Loop

    MsgBox("Ambient Temp (C) - CountRow - " & CountRow)

推荐阅读