ExcelTip.Net留存知识帖 ---【注:附件之前被网盘供应商清空后,现已修复-现已修复-现已修复为本地下载!】
现在位置:首页 > E问E答 > Excel VBA > 如何返回首尾相连的七星彩号码?

如何返回首尾相连的七星彩号码?

作者:绿色风 分类: 时间:2022-08-17 浏览:98
楼主
liuguansky
Q:如何依号码明细返回首尾相连的七星彩号码?
A:用如下代码可以实现 :

  1. Sub justtest()
  2.     Dim arr1, arr2, arr3, arr4, arr5, dic, i1, i2, i3, i4, i5, str1$
  3.     Set dic = CreateObject("scripting.dictionary")
  4.     arr1 = Cells(2, 1).Resize(Cells(1, 1).End(4).Row - 1, 1).Value
  5.     arr2 = Cells(2, 2).Resize(Cells(1, 2).End(4).Row - 1, 1).Value
  6.     arr3 = Cells(2, 3).Resize(Cells(1, 3).End(4).Row - 1, 1).Value
  7.     arr4 = Cells(2, 4).Resize(Cells(1, 4).End(4).Row - 1, 1).Value
  8.     arr5 = Cells(2, 5).Resize(Cells(1, 5).End(4).Row - 1, 1).Value
  9.     For i1 = 1 To UBound(arr1, 1)
  10.         For i2 = 1 To UBound(arr2, 1)
  11.             If Right$(arr1(i1, 1), 2) = Left$(arr2(i2, 1), 2) Then
  12.                 For i3 = 1 To UBound(arr3, 1)
  13.                     If Right$(arr2(i2, 1), 2) = Left$(arr3(i3, 1), 2) Then
  14.                         For i4 = 1 To UBound(arr4, 1)
  15.                             If Right$(arr3(i3, 1), 2) = Left$(arr4(i4, 1), 2) Then
  16.                                 For i5 = 1 To UBound(arr5, 1)
  17.                                     If Right$(arr4(i4, 1), 2) = Left$(arr5(i5, 1), 2) Then
  18.                                         str1 = "'" & arr1(i1, 1) & Mid$(arr3(i3, 1), 1, 1) & arr5(i5, 1)
  19.                                         If Not dic.exists(str1) Then
  20.                                             dic.Add str1, ""
  21.                                         End If
  22.                                     End If
  23.                                 Next i5
  24.                             End If
  25.                         Next i4
  26.                     End If
  27.                 Next i3
  28.             End If
  29.         Next i2
  30.     Next i1
  31.     Range("G:G").ClearContents
  32.     If dic.Count > 0 Then
  33.         Range("g1") = dic.Count & "注"
  34.         Range("g2").Resize(dic.Count, 1) = Application.Transpose(dic.keys)
  35.     End If
  36.     Set dic = Nothing
  37. End Sub
具体示例文件如下:
2楼
い卋玑┾宝珼
终于不小心膜拜到花爷了
3楼
后知
感谢花爷的分享         

免责声明

有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素, 经与ExcelTip.Net站长Apolloh商议并征得其同意, 现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示, 供有需要的人士查询使用,也慰缅曾经的论坛时代。 所示各个帖子的原作者如对版权有异议, 可与本人沟通提出,或于本站点留言,我们会尽快处理。 在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一

评论列表
sitemap