Presentation is loading. Please wait.

Presentation is loading. Please wait.

巨集錄製 VB for Application (VBA). 巨集錄製 命令 – 檢視 / 巨集 練習 : – 錄製巨集名為 : test – 在 c4 輸入 巨集 並設為 綠色 – 停止巨集錄製,並檢視巨集.

Similar presentations


Presentation on theme: "巨集錄製 VB for Application (VBA). 巨集錄製 命令 – 檢視 / 巨集 練習 : – 錄製巨集名為 : test – 在 c4 輸入 巨集 並設為 綠色 – 停止巨集錄製,並檢視巨集."— Presentation transcript:

1 巨集錄製 VB for Application (VBA)

2 巨集錄製 命令 – 檢視 / 巨集 練習 : – 錄製巨集名為 : test – 在 c4 輸入 巨集 並設為 綠色 – 停止巨集錄製,並檢視巨集

3 VBA 命令 – 檢視 / 巨集 之檢視巨集 下 – 輸入 find_noun 後建立 巨集程式輸入 Sub find_noun() End Sub

4 VBA (simple) 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

5 找到 學期成績位置 –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

6 改屬性 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

7 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


Download ppt "巨集錄製 VB for Application (VBA). 巨集錄製 命令 – 檢視 / 巨集 練習 : – 錄製巨集名為 : test – 在 c4 輸入 巨集 並設為 綠色 – 停止巨集錄製,並檢視巨集."

Similar presentations


Ads by Google