Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1687|回复: 1

[已解决]请教如何得到这个结果

[复制链接]
发表于 2016-7-16 13:37 | 显示全部楼层 |阅读模式
http://pan.baidu.com/s/1qYQrfTq
T列的结果是我想要的,由于上存不了附件,所以我把它放在网盘里。
最佳答案
2016-7-17 22:26
得到的数值和你的有点小小出入,请测试:
  1. Sub wanao()
  2.     Dim x As Integer, y As Integer, S1 As Integer, S2 As Integer, jiShu As Integer
  3.     S1 = 14
  4.     S2 = 19
  5.     For x = 2 To 12
  6.         jiShu = 0
  7.         For y = 8 To 3 Step -1
  8.             If Cells(x, y) <> "" Then
  9.                 jiShu = jiShu + 1
  10.                 Cells(x, S1 - jiShu) = Cells(x, y)
  11.                 If jiShu = 1 Then
  12.                     Cells(x, S2 - jiShu) = 100
  13.                 Else
  14.                     Cells(x, S2 - jiShu) = 100 / Cells(x, "m") * Cells(x, S1 - jiShu)
  15.                 End If
  16.             End If
  17.             If jiShu = 4 Then
  18.                 Cells(x, "t") = Abs(Cells(x, "r") - Cells(x, "q")) + Abs(Cells(x, "q") - Cells(x, "p")) + Abs(Cells(x, "p") - Cells(x, "o"))
  19.                 Exit For
  20.             End If
  21.         Next
  22.     Next
  23. End Sub
复制代码
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-7-17 22:26 | 显示全部楼层    本楼为最佳答案   
得到的数值和你的有点小小出入,请测试:
  1. Sub wanao()
  2.     Dim x As Integer, y As Integer, S1 As Integer, S2 As Integer, jiShu As Integer
  3.     S1 = 14
  4.     S2 = 19
  5.     For x = 2 To 12
  6.         jiShu = 0
  7.         For y = 8 To 3 Step -1
  8.             If Cells(x, y) <> "" Then
  9.                 jiShu = jiShu + 1
  10.                 Cells(x, S1 - jiShu) = Cells(x, y)
  11.                 If jiShu = 1 Then
  12.                     Cells(x, S2 - jiShu) = 100
  13.                 Else
  14.                     Cells(x, S2 - jiShu) = 100 / Cells(x, "m") * Cells(x, S1 - jiShu)
  15.                 End If
  16.             End If
  17.             If jiShu = 4 Then
  18.                 Cells(x, "t") = Abs(Cells(x, "r") - Cells(x, "q")) + Abs(Cells(x, "q") - Cells(x, "p")) + Abs(Cells(x, "p") - Cells(x, "o"))
  19.                 Exit For
  20.             End If
  21.         Next
  22.     Next
  23. End Sub
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-26 19:24 , Processed in 0.257339 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表