[英]Excel: How to auto-populate cell with data using static column with a row dependent on another cell?
[英]Auto-populate Cell In Excel Based On Contents Of Another Cell
我很難掌握編碼。 我的Excel工作表包含一個包含分數的單元格。 我希望無論分數是在其他單元格中填充評分:
您可以編寫一個簡單的UDF
Option Explicit
Public Function Score(ByVal rng As Range) As String
If rng.Count > 1 Then
Score = "Select single cell"
Exit Function
End If
Select Case rng
Case 4, 5
Score = "Excellent"
Case 2, 3
Score = "Above Average"
Case 1, 0, -1
Score = "Average"
Case -2, -3
Score = "Below Average"
Case -4, -5
Score = "Poor"
Case Else
Score = "Unknown"
End Select
End Function
在工作表中使用UDF的示例:
開發人員選項卡已添加到功能區>使用Alt + F11打開並添加標准模塊並在其中放置代碼:
標准模塊中的代碼:
如果您將數據設置為表格並在右上角的單元格中輸入公式,它將自動在所有行的下方填充公式:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.