0
我需要在多個選項卡上運行代碼才能爲我的員工提高效率。通過10個選項卡擴展代碼
我不能讓它通過其他表循環。
Public Sub PrinterButton_Click()
Dim xBad As Integer
'checks for bad tariffs
For h = 18 To 219 '18 to 219 - number of rows for tariffs
For ae = 6 To 6 'keep 6to 6 to work
If Range("AE" & ae) > 0 Then
If Range("D" & h) = "8473.30.9100" Or Range("D" & h) = "7117.19.6000" Or Range("D" & h) = "7117.90.4500" Or Range("D" & h) = "7117.90.6000" Or Range("D" & h) = "8473309100" Or Range("D" & h) = "7117904500" Or Range("D" & h) = "7117906000" Or Range("D" & h) = "7117906000" Then
MsgBox "You have a prohibited tariff in row " & h
xBad = 1
ElseIf Range("C" & h) = "CN" Or Range("C" & h) = "cn" Or Range("C" & h) = "Cn" Or Range("C" & h) = "cN" Then
If Range("D" & h) = "8501.61.0000" Or Range("D" & h) = "8507.20.8030" Or Range("D" & h) = "8507.20.8040" Or Range("D" & h) = "8507.20.8060" Or Range("D" & h) = "8507.20.8090" Or Range("D" & h) = "8541.40.6020" Or Range("D" & h) = "8541.40.6030" Or Range("D" & h) = "8501.31.8000" Then
MsgBox "You have a prohibited tariff from China in row " & h
xBad = 1
ElseIf Range("D" & h) = "8501610000" Or Range("D" & h) = "8507208030" Or Range("D" & h) = "8507208040" Or Range("D" & h) = "8507208060" Or Range("D" & h) = "8507208090" Or Range("D" & h) = "8541406020" Or Range("D" & h) = "8541406030" Or Range("D" & h) = "8501318000" Then
MsgBox "You have a prohibited tariff from China in row " & h
xBad = 1
End If
End If
Else
End If
Next ae
Next h
If xBad <> 1 Then
Dim Rng As Range
Dim c As Range
On Error Resume Next
Set Rng = Cells.SpecialCells(xlCellTypeConstants, 2)
For Each c In Rng
c.Value = UCase(c.Value)
Next c
'prints the sheets
If Range("D194") <> "" Then
Range("A1:M219").Select
Selection.PrintOut copies:=1
ElseIf Range("D150") <> "" Then
Range("A1:M175").Select
Selection.PrintOut copies:=1
ElseIf Range("D106") <> "" Then
Range("A1:M131").Select
Selection.PrintOut copies:=1
ElseIf Range("D62") <> "" Then
Range("A1:M87").Select
Selection.PrintOut copies:=1
Else
Range("A1:M43").Select
Selection.PrintOut copies:=1
End If
End If
Range("C1").Select
End Sub