excel宏中的IF编写,请高手帮忙!最佳答案送高分!

来源:百度知道 编辑:UC知道 时间:2024/06/09 02:36:12
我编写了一个fliter的宏,想在输入某查找条件没有对应记录的时候弹出重新输入条件的对话框,应该怎么用if语句编写?
就是不明白条件语句怎么编写,下面我编写的宏,就是要在最后那个msgbox那个地方加个if
Sub SelectClient()
'
' SelectClient Macro
'
' Keyboard Shortcut: Ctrl+Shift+I
'
ActiveWindow.SmallScroll Down:=84
Range("A100").Select
ActiveCell.FormulaR1C1 = InputBox("Please enter last name.")
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("C93").Select
Range("A9:I97").AdvancedFilter Action

这个应该是你想要的结果了:
Sub SelectClient()
'
' SelectClient Macro
'
' Keyboard Shortcut: Ctrl+Shift+I
'
On Error GoTo EXIT_SUB
ActiveWindow.SmallScroll Down:=84
Range("A100").Select
ActiveCell.FormulaR1C1 = InputBox("Please enter last name.")
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("C93").Select
Range("A9:I97").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range(&quo