Board logo

標題: 請問這個Workbook哪裡有錯誤呢? [打印本頁]

作者: coafort    時間: 2023-7-20 13:09     標題: 請問這個Workbook哪裡有錯誤呢?

本帖最後由 coafort 於 2023-7-20 13:10 編輯

請問各位大大
Workbook這樣會出錯
編譯出錯 發現不確定的名稱Workbook_SheetChange
請問是哪裡的問題呢
謝謝

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
With Target
    If .Worksheet.Index = 1 Then Exit Sub
    If .Worksheet.Index > 3 Then Exit Sub
    If .Column = 41 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 27 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 1 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 16 Then
         If .Row < 3 Then Exit Sub
         If .Row > 40 Then Exit Sub
         If .Row >= 24 And .Row <= 26 Then Exit Sub
         If .Count > 1 Then Exit Sub
         If .Value = "" Then .Offset(, 1).ClearContents
      End If
    If .Column = 20 Then
         If .Row < 3 Then Exit Sub
         If .Row > 40 Then Exit Sub
         If .Row >= 24 And .Row <= 26 Then Exit Sub
         If .Count > 1 Then Exit Sub
         If .Value = "" Then .Offset(, 1).ClearContents
      End If
  End With
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
With Target
    If .Worksheet.Index > 4 Then Exit Sub
    If .Worksheet.Index > 8 Then Exit Sub
    If .Column = 45 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 30 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 1 Then
        If .Count > 1 Then Exit Sub
        If .Value = "" Then .Offset(, 1).ClearContents
        End If
    If .Column = 17 Then
         If .Row < 3 Then Exit Sub
         If .Row > 40 Then Exit Sub
         If .Row >= 24 And .Row <= 26 Then Exit Sub
         If .Count > 1 Then Exit Sub
         If .Value = "" Then .Offset(, 1).ClearContents
      End If
    If .Column = 22 Then
         If .Row < 3 Then Exit Sub
         If .Row > 40 Then Exit Sub
         If .Row >= 24 And .Row <= 26 Then Exit Sub
         If .Count > 1 Then Exit Sub
         If .Value = "" Then .Offset(, 1).ClearContents
      End If
  End With
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)