Download presentation
Presentation is loading. Please wait.
Published byLauren Knight Modified over 9 years ago
1
VB for Application (VBA)
2
Sub find_noun() Dim range1 As Range Dim cell1 As Range Dim strign1 As String string1 = InputBox(" 請輸入範圍 ") Set range1 = Range(string1) For Each cell1 In range1 If cell1.Value = " 學期成績 " Then MsgBox Title:=" 輸出 ", prompt cell1.Address Next cell1 End Sub
3
找到 學期成績 –For Each cell1 In range1 – If cell1.Value = " 學期成績 " Then cell1.Select: Exit For –Next cell1 找到 成績 小於 60 分 –Set cell2 = ActiveCell.Offset(rowoffset:=i, columnoffset:=0) – If cell2.Value < 60 Then 找出那姓名 –MsgBox cell2.Offset(rowoffset:=0, columnoffset:=-6).Value
4
改屬性 With cell2.Offset(rowoffset:=0, columnoffset:=-6).Font.Underline = xlUnderlineStyleNone.ColorIndex = 3 End With With cell2.Offset(rowoffset:=0, columnoffset:=-6).Interior.ColorIndex = 43.Pattern = xlSolid.PatternColorIndex = xlAutomatic End With
5
Sub find_noun() Dim range1 As Range Dim cell1 As Range Dim cell2 As Range Dim strign1 As String string1 = InputBox(" 請輸入範圍 ") Set range1 = Range(string1) For Each cell1 In range1 If cell1.Value = " 學期成績 " Then cell1.Select: Exit For Next cell1 For i = 1 To 20 Step 1 Set cell2 = ActiveCell.Offset(rowoffset:=i, columnoffset:=0) If cell2.Value < 60 Then MsgBox cell2.Offset(rowoffset:=0, columnoffset:=-6).Value With cell2.Offset(rowoffset:=0, columnoffset:=-6).Font.Underline = xlUnderlineStyleNone.ColorIndex = 3 End With With cell2.Offset(rowoffset:=0, columnoffset:=-6).Interior.ColorIndex = 43.Pattern = xlSolid.PatternColorIndex = xlAutomatic End With End If Next i End Sub
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.