vba设置批注和Select Case应用

 


Dim BrandStr As String

'获取品牌名称
BrandStr = Sheets("Sheet1").Cells(Target.Row, 2).Value

'根据产品名称条件设置行
    Select Case BrandStr
        Case "Time and Tru 普楦"
            If Sheets("Sheet1").Cells(Target.Row, 11).Comment Is Nothing Then
                '设置批注
                Sheets("Sheet1").Cells(Target.Row, 11).AddComment "提示:请填写单码或者双码,,如 7-8。"
                Sheets("Sheet1").Cells(Target.Row, 11).Comment.Visible = False
            Else
                '如果有批注,直接修改批注内容
                Sheets("Sheet1").Cells(Target.Row, 11).Comment.Text "提示:请填写单码或者双码,,如 7-8。"
            End If
        Case "Time and Tru 宽楦"
            If Sheets("Sheet1").Cells(Target.Row, 11).Comment Is Nothing Then
                '设置批注
                Sheets("Sheet1").Cells(Target.Row, 11).AddComment "提示:仅填写数字,半码用?表示,尺码与半码之间没有空格隔开,如 7?W。"
                Sheets("Sheet1").Cells(Target.Row, 11).Comment.Visible = False
            Else
                '如果有批注,直接修改批注内容
                Sheets("Sheet1").Cells(Target.Row, 11).Comment.Text "提示:仅填写数字,半码用?表示,尺码与半码之间没有空格隔开,如 7?W"
            End If
        Case "BRAHMA 普楦"
            '设置款式
            Sheets("Sheet1").Cells(Target.Row, 10).Value = "MEN'S"
        Case "BRAHMA 宽楦"
            '设置款式
            Sheets("Sheet1").Cells(Target.Row, 10).Value = "MEN'S"
        Case "GEORGE 普楦"
            '设置款式
            Sheets("Sheet1").Cells(Target.Row, 10).Value = "Men's"
        Case "GEORGE 宽楦"
            '设置款式
            Sheets("Sheet1").Cells(Target.Row, 10).Value = "Men's"
        Case "Athletic Works"
            '设置款式
            With Sheets("Sheet1").Cells(Target.Row, 10).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="MEN'S,WOMEN'S,BOY'S,YOUTH,BIG BOY'S"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = "请选择下拉框内的RFID产品!"
            .ShowInput = True
            .ShowError = True
            End With
        Case "SHAQ"
            '设置款式
            With Sheets("Sheet1").Cells(Target.Row, 10).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Boy's,Big Boy's"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = "请选择下拉框内的RFID产品!"
            .ShowInput = True
            .ShowError = True
            End With
        Case "AND1"
            '设置款式
            With Sheets("Sheet1").Cells(Target.Row, 10).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Mens,无"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = "请选择下拉框内的RFID产品!"
            .ShowInput = True
            .ShowError = True
            End With
        Case "AVIA"
            '设置款式
            With Sheets("Sheet1").Cells(Target.Row, 10).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Women's,Men's,Girl's"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = "请选择下拉框内的RFID产品!"
            .ShowInput = True
            .ShowError = True
            End With
        Case "TREDSAFE"
            '设置款式
            With Sheets("Sheet1").Cells(Target.Row, 10).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="Unisex,WOMEN,MEN,WOMEN'S"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = "请选择下拉框内的RFID产品!"
            .ShowInput = True
            .ShowError = True
            End With
        Case Else
            MsgBox "其他"
            '清空批注
            Sheets("Sheet1").Cells(Target.Row, 11).ClearComments
            '清空款式
            Sheets("Sheet1").Cells(Target.Row, 10).Value
    
    End Select
    

 

posted @ 2021-01-19 15:00  蜗牛的礼物  阅读(378)  评论(0编辑  收藏  举报