VBA

工作薄的某个工作表怎么表示?如工作薄为PriceList有两个工作表sheet1和sheet2.下面的代码第二行有错,Found为空值,事实上不是,什么原因呢?
Private Function GetPriceInt(PriceList As Worksheet, Item As Range)
    Set Found = PriceList.Worksheets(1).Cells(1, 1).EntireColumn.Find(Item)
    If Not Found Is Nothing Then
        GetPriceInt = Found.Offset(0, 1)
    Else
        GetPriceInt = 0
    End IfEnd Function

解决方案 »

  1.   

    Private Function GetPriceInt(PriceList As Worksheet, Item As Range) 'Private Function GetPriceInt(PriceList As WorkBook, Item As Range) '工作本是 WorkBook. Worksheet 就是工作表.所以,后面的都错了,不用说了.
        Set Found = PriceList.Worksheets(1).Cells(1, 1).EntireColumn.Find(Item) 
        If Not Found Is Nothing Then 
            GetPriceInt = Found.Offset(0, 1) 
        Else 
            GetPriceInt = 0 
        End If End Function
      

  2.   


    Private Function GetPriceInt(PriceList As Worksheet, Item As Range)'Private Function GetPriceInt(PriceList As WorkBook, Item As Range) 
    '工作本是 WorkBook. Worksheet 就是工作表.所以,后面的都错了,不用说了.
     
        Set Found = PriceList.Worksheets(1).Cells(1, 1).EntireColumn.Find(Item) 
        If Not Found Is Nothing Then 
            GetPriceInt = Found.Offset(0, 1) 
        Else 
            GetPriceInt = 0 
        End If End Function