可以先用錄製宏功能,學習一下vba程式碼,除錯的時候多用msgbox函式和 msdn的官方幫助 google用EXCEL VBA實現------------------------------------------------------------------------------------Sub Macro4()"" Macro1 MacroFor i = 1 To 2ActiveSheet.CheckBoxes.Add(Cells(i, 1).Left, Cells(i, 1).Top, 24, 16.5).Select "在cells(i,1)處新增複選框ActiveSheet.Shapes("Check Box " + Str(i)).SelectSelection.Characters.Text = "" "把複選框右邊系統自帶的註釋清空With Selection.Value = xlOff.LinkedCell = "$B$" + Trim(Str(i)) "如果i=1的話,則在B1單元格處顯示A1單元格中的複選框是否被選中" MsgBox """" + "$D$" + Trim(Str(i)) + """"" MsgBox """" + "$D$1" + """".Display3DShading = FalseEnd WithNext iRange("E5").SelectEnd Sub-------------------------------------------------------------------------------------------------------------------------Private Sub Worksheet_SelectionChange(ByVal Target As Range)" [a1] = "單元格 "" [b1] = "第一行頂端到該單元格頂端的距離: "" [c1] = "從A列左邊界至該單元格左邊界的距離: "[a2] = Target.Address ’單元格在第幾行第幾列[b2] = Target.Top ‘單元格離上邊界的距離[c2] = Target.Left ’單元格離左邊界的距離[d2] = Target.Height ’單元格行高[e2] = Target.Width ‘單元格列寬字串轉數值函式 val數值轉字串函式 str
可以先用錄製宏功能,學習一下vba程式碼,除錯的時候多用msgbox函式和 msdn的官方幫助 google用EXCEL VBA實現------------------------------------------------------------------------------------Sub Macro4()"" Macro1 MacroFor i = 1 To 2ActiveSheet.CheckBoxes.Add(Cells(i, 1).Left, Cells(i, 1).Top, 24, 16.5).Select "在cells(i,1)處新增複選框ActiveSheet.Shapes("Check Box " + Str(i)).SelectSelection.Characters.Text = "" "把複選框右邊系統自帶的註釋清空With Selection.Value = xlOff.LinkedCell = "$B$" + Trim(Str(i)) "如果i=1的話,則在B1單元格處顯示A1單元格中的複選框是否被選中" MsgBox """" + "$D$" + Trim(Str(i)) + """"" MsgBox """" + "$D$1" + """".Display3DShading = FalseEnd WithNext iRange("E5").SelectEnd Sub-------------------------------------------------------------------------------------------------------------------------Private Sub Worksheet_SelectionChange(ByVal Target As Range)" [a1] = "單元格 "" [b1] = "第一行頂端到該單元格頂端的距離: "" [c1] = "從A列左邊界至該單元格左邊界的距離: "[a2] = Target.Address ’單元格在第幾行第幾列[b2] = Target.Top ‘單元格離上邊界的距離[c2] = Target.Left ’單元格離左邊界的距離[d2] = Target.Height ’單元格行高[e2] = Target.Width ‘單元格列寬字串轉數值函式 val數值轉字串函式 str