返回列表 上一主題 發帖

儲存格裡的註解

回復 10# jsc0518
搭配重算事件
  1. Private Sub Worksheet_Calculate() '僅適用VLOOKUP函數
  2. Dim A As Range, C As Range, Rng As Range, Sht As Worksheet, Mc As Comment
  3. For Each A In Sheet1.UsedRange.SpecialCells(xlCellTypeFormulas)
  4. If A.FormulaLocal Like "=VLOOKUP(*,*,*,*)" Then '是否是VLOOKUP函數
  5. fx = Split(Split(A.Formula, "(")(1), ",") '公式分解
  6. Set Rng = Sheets(Split(fx(1), "!")(0)).Range(Split(fx(1), "!")(1)) '來源資料範圍
  7.     x = Range(fx(0)) '第一欄的搜尋值
  8.     r = Rng.Find(x).Row '找到來源資料的列號
  9.     k = Val(fx(2)) + Rng.Column - 1 '來源資料位於整個工作表的欄號
  10.     If Not A.Comment Is Nothing Then A.Comment.Delete '刪除公式儲存格內的註解
  11.     Set Mc = Rng.Parent.Cells(r, k).Comment '來源資料的註解
  12.     If Not Mc Is Nothing Then A.AddComment Rng.Parent.Cells(r, k).Comment.Text '加入來源註解
  13. End If
  14. Next
  15. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 11# Hsieh
Dear Hsieh,
感謝您的熱心回覆,有個問題與您請教

.若"來源資料"是在Sheet3F4欄列開始,下面語法需要修改哪裡呢?
Set Rng = Sheets(Split(fx(1), "!")(0)).Range(Split(fx(1), "!")(1)) '來源資料範圍


謝謝您
Just do it.

TOP

        靜思自在 : 待人退一步,愛人寬一寸,就會活得很快樂。
返回列表 上一主題