簡體   English   中英

當另一個框在excel(VBA)中具有某個值時,如何引用msgBox中的單元格。

[英]How to reference a cell in a msgBox when another box has a certain value in excel (VBA).

當該行中的某個單元格達到某個值時,我試圖將一個相應的單元格輸入到msgBox中。 例如,如果C1> 3.45,則我需要一個消息框,說“在“ + Range(” A1“)+”處的值太高。 這將擴展到整個數組。

我一直在嘗試修改簡單的腳本。

Private Sub Worksheet_Change(ByVal Target As Range)
    Set Target = Me.Range("C1:C100")
    If Target.Value > 3.45 Then
        MsgBox "The Value at "+ Range("A1:A100") + " exceeded limit."
    End If
End Sub

我知道我錯過了一些東西,但我不知道如何關聯數字並讓它們返回。 我知道我可以搭配比賽並利用

 Set targetRange = [range]
 targetRange.FormulaArray = "=[insert array formula]"

但是我似乎無法讓它們正常工作。

預先感謝您的幫助。

為什么不嘗試類似的東西

for i = 1 to 100
  if cells(i, 3) > 3.45 then
    msgbox "Cell C" & i & " is too high. The corresponding time stamp is " & cells(i, 1) & "."
  end if
next i

每當該范圍內的單元格“過高”時,這都會提醒用戶。

單線無圈(好玩-難以理解!)

MsgBox Join(Filter(Application.Transpose(Application.Evaluate("=IF(ISNUMBER(C1:C100),IF(C1:C100>3.45,""C""& ROW(C1:C100),""x""),""x"")")), "x", False), ",")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM