当前位置:网站首页>Excel · VBA custom function to obtain multiple cell values
Excel · VBA custom function to obtain multiple cell values
2022-04-23 11:01:00 【Schrodinger_ fifty-one】
《excel Let's ask questions - Cell multi value 》, Returns the value of the cell that appears the most times in multiple cells
Applicable to multiple cells and cell ranges
Function majority(ParamArray args())
' Function definition majority( Cell 1, Cell 2,...) Returns the value of the cell with the most occurrences of multiple cells
Dim a, aa, t, i, k, v, m, x, dict As Object, result
Set dict = CreateObject("scripting.dictionary")
For Each a In args
If Not IsArray(a) Then
t = a.Value
dict(t) = dict(t) + 1
Else
For Each aa In a
t = aa.Value
dict(t) = dict(t) + 1
Next
End If
Next
k = dict.keys
v = dict.Items
m = WorksheetFunction.Max(v) ' Most times
result = Array()
For i = 0 To dict.count - 1: ' Ergodic dictionary
If v(i) = m Then
x = UBound(result) + 1
ReDim Preserve result(x)
result(x) = k(i)
End If
Next
majority = Join(result, ",")
End Function
give an example
版权声明
本文为[Schrodinger_ fifty-one]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231056567131.html
边栏推荐
- 比深度学习更值得信赖的模型ART
- The difference between restful and soap
- Ueditor -- limitation of 4m size of image upload component
- Embedded related surface (I)
- SWAT - Introduction to Samba web management tool
- How does the swagger2 interface import postman
- Anaconda3 installation
- UDP basic learning
- Introduction to data analysis 𞓜 kaggle Titanic mission (IV) - > data cleaning and feature processing
- Leetcode22: bracket generation
猜你喜欢
语雀文档编辑器将开源:始于但不止于Markdown
Diary of dishes | Blue Bridge Cup - hexadecimal to octal (hand torn version) with hexadecimal conversion notes
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
MySQL how to merge the same data in the same table
26. 删除有序数组中的重复项
Xshell+Xftp 下载安装步骤
Learning Notes 6 - Summary of several deep learning convolutional neural networks
SQL Server 递归查询上下级
《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
【leetcode】102.二叉树的层序遍历
随机推荐
Notes on concurrent programming of vegetables (V) thread safety and lock solution
Typora operation skill description (I) md
Learning note 5 - gradient explosion and gradient disappearance (k-fold cross verification)
Visual solutions to common problems (VIII) mathematical formulas
Using El popconfirm and El backtop does not take effect
语雀文档编辑器将开源:始于但不止于Markdown
Learning Notes 6 - Summary of several deep learning convolutional neural networks
JVM - common parameters
Kaggle - real battle of house price prediction
How can swagger2 custom parameter annotations not be displayed
妊娠箱和分娩箱的区别
ID number verification system based on visual structure - Raspberry implementation
Restful、SOAP、RPC、SOA、微服务之间的区别
Introduction to data analysis 𞓜 kaggle Titanic mission (III) - > explore data analysis
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
C语言之结构体(进阶篇)
Detailed explanation of typora Grammar (I)
ConstraintLayout布局
HuggingFace
VIM + ctags + cscope development environment construction guide