excel - 我是初学者,如何在 VBA excel 中获取变量中的单元格值?
问题描述
我正在尝试比较 excel 列中的单元格值。如果数字从 8 变为 7,我必须插入一个空白行。所以我试图取变量中的值,然后比较它们。但我无法在变量中设置值:(
解决方案
简要说明如何比较:
Sub Compare()
Dim CellValue As Integer, CompareWithValue As Integer
CellValue = Sheet1.Range("A1").Value '<= The value in the A1 of Sheet1
CompareWithValue = Sheet1.Range("A2").Value '<= The value in the A2 of
Sheet1
If CellValue > CompareWithValue Then '<= Compare if CellValue is greater than
CompareWithValue (here you can also use < or =)
'what do you want to happen if the above condition is true
End If
End Sub
推荐阅读
- php - 如何使用右连接和 MYSQL 案例获取两列的数据
- google-maps - 查找街道的起点和终点节点
- javascript - 列表中未定义的值
- javascript - JQ 事件在按 datatable.js 的提取行排序上没有激活
- css - 在不改变大小的情况下创建一侧边框在引导网格中
- mongodb - Mongo - 保存文档时出错:1 在写入数据库时不是主要的
- android - 本地通知实现
- javascript - 找不到 TypeScript 自定义定义文件
- asp.net - Asp.net mvc 5 身份 smtp 连接
- c++ - 如何在 if 语句中放入二维字符串数组?