昨天下午开始学习的vba,累死了,肯定有bug,待调试

vba程序如下:

 Dim aSum As Integer
Dim tSum As Integer
Dim judge() As Integer
Dim arrMax As Integer
Dim arr
Dim location() As Integer Function Test()
Dim arrWmax As Integer
Dim Rng As Range
Dim beginRow As Integer
Dim beginLine As Integer Set Rng = Application.InputBox(prompt:="Please Select....", Type:=)
rr = Rng.Address
beginRow = Rng.Column
beginLine = Rng.Row arr = Range(rr)
aSum =
arrMax = UBound(arr)
arrWmax = UBound(arr, ) For loca = To arrMax
location(loca) = beginLine
beginLine = beginLine +
Next For col = To arrWmax 'modify
tSum = arr(, col)
Call subTest(, beginRow)
Next End Function Function subTest(n As Integer, beginRow As Integer)
If aSum > tSum Then
Exit Function
End If Dim i As Integer
Dim j As Integer
If aSum = tSum Then
For i = To n
If judge(i) = Then
Sheets().Cells(location(i), beginRow).Interior.Color = vbRed
End If
Next Exit Function
End If If n = arrMax Then
Exit Function
End If For j = n To arrMax
If judge(j) = Then
judge(j) =
aSum = aSum + arr(j, )
Call subTest(j, beginRow) judge(j) =
aSum = aSum - arr(j, )
If j < arrMax Then
While arr(j, ) = arr(j + , )
j = j +
Wend
End If
End If
Next End Function

[vba]excel中求选中数据和为给定数所有的组合的更多相关文章

  1. 将excel中某列数据中,含有指定字符串的记录取出,并生成用这个字符串命名的txt文件

    Python 一大重要的功能,就是可处理大量数据,那分不开的即是使用Excel表格了,这里我做下学习之后的总结,望对我,及广大同仁们是一个帮助Python处理Excel数据需要用到2个库:xlwt 和 ...

  2. java程序转换excel中科学记数法的数据为date类型

    今天出于某些原因从mongodb数据库中导出了一些数据,为了更直观的发送给其他人查阅,便使用mongoVUE的导出为excel功能.   但是导出后出现了一个问题,里边有一列存储时间的,存储的是lon ...

  3. Excel: 使用Countif函数来去掉Excel中重复的数据

    如果使用Ruby脚本,uniq函数就能搞定一切.不过我们现在还是讨论怎么用excel的Countif函数吧. 假设Excel中有一列数据:

  4. 接口测试中读取excel中的请求数据含有中文问题,UnicodeEncodeError: 'latin-1' codec can't encode character '\u5c0f' in position

    错误信息:UnicodeEncodeError: 'latin-1' codec can't encode character '\u5c0f' in position 31: Body ('小') ...

  5. VBS读取txt文档数据查找Excel中单元格数据符合条件的剪切到工作表2中

    Dim fso,f,a set oExcel = CreateObject( "Excel.Application" ) oExcel.Visible = false '4) 打开 ...

  6. VBA Excel 对比两列数据

    Sub Md() ' ' Macro1 Macro ' 宏由 BX 录制,时间: 2012-6-8 ' 宏中的列数可以输入 A - IV 也可以输入 1-256 ' Dim i%, j%, i1%, ...

  7. Excel 中批量处理数据(改成 json 格式)

    如下excel: 需要处理成下面的效果: 方法: 在 C2 中输入公式: ="{"""&"code"&"" ...

  8. python - requests从excel中获取测试用例数据

    HttpRequests.py #-*- coding:utf-8 -*- import requests class HttpRequests(): def http_requests(self,u ...

  9. VBA excel中表示列的字母换成数字

    出自这里 数字转列标: Split(Cells(1,).Address(1,0),"$")(0)    '将1-256替换红色的1就可以 Cells(1, a) 选中对应的第一行第 ...

随机推荐

  1. Hadoop-chd4.4.0安装

    Hadoop-cdh4下载地址: http://www.cloudera.com/content/cloudera-content/cloudera-docs/CDHTarballs/3.25.201 ...

  2. 《java数据结构与算法》笔记-CH4-8栈结构实现后缀表达式计算结果

    /** * 中缀表达式转换成后缀表达式: 从输入(中缀表达式)中读取的字符,规则: 操作数: 写至输出 左括号: 推其入栈 右括号: 栈非空时重复以下步骤--> * 若项不为(,则写至输出: 若 ...

  3. var隐式类型

    var dogName = "ruiky"; 1.[编译器]会在编译时自动根据值的类型推断这个变量的类型:       2.变量类型不可更改:因为声明的时候已经确定类型了. 3.可 ...

  4. Sharding & IDs at Instagram(转)

    英文原文:http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram 译文:http://ww ...

  5. Django 1.6 最佳实践: 如何正确使用 Signal(转)

    原文:http://www.weiguda.com/blog/38/ 如何正确的使用signal: 简单回答是: 在其他方法无法使用的情况下, 才最后考虑使用signal. 因为新的django开发人 ...

  6. python简单网络服务器

    对于服务器来说建立TCP连接的过程分为4步: 1.建立socket对象:这里与客户端一样,依然是: s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) ...

  7. ACM之递推递归

    Hdu 2569 突破蝙蝠的包围,yifenfei来到一处悬崖面前,悬崖彼岸就是前进的方向,好在现在的yifenfei已经学过御剑术,可御剑轻松飞过悬崖. 现在的问题是:悬崖中间飞着很多红,黄,蓝三种 ...

  8. 【PAT】1020. Tree Traversals (25)

    Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and i ...

  9. hdoj 5358 First One

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 一开始一直以为是一道数学题,在找有什么规律化简Log2(S(i,j)),结束了以后才造  ⌊lo ...

  10. android获取手机的所有通讯录的号码和sim卡号码

    ============personer================================================ package com.qgc.cantent.entity; ...