math转置在Excel中
大家好! 我目前正在试图找出在Excel中的东西,然后在VBScript中实现。 我必须在math上转置一些matrix(10 * 10或5r * 10c)在matrix中:
------------------------------- | .. | .. | .. | .. | .. | .. | | 21 | 22 | 23 | 24 | 25 | .. | | 11 | 12 | 13 | 14 | 15 | .. | | 1 | 2 | 3 | 4 | 5 | .. | -------------------------------
必须成为
------------------------------- | .. | .. | .. | .. | .. | .. | | 3 | 13 | 23 | 33 | 43 | .. | | 2 | 12 | 22 | 32 | 42 | .. | | 1 | 11 | 21 | 31 | 41 | .. | -------------------------------
现在我不是一个math家(现在我更不是程序员),但是我想出了: F(y)=((MOD(x,10)-1)*10)+(1+((x-MOD(x,10))/10))
( x
是前块a中的值, y
是前块中的值)。 (例如10
)。
在VBScript中,我首先写了下面的内容:
函数GetPosInSrcRack(Pos) Dim PlateDef(9),x,y,i,tmp “板块定义” ReDim tmp(UBound(PlateDef)) 对于x = 0到UBound(PlateDef) PlateDef(x)= tmp 下一个 我= 1 对于x = 0到UBound(PlateDef) 对于y = 0到UBound(PlateDef(x)) PlateDef(x)(y)= i i =(i + 1) 下一个 下一个 'Dim msg'检查定义 '对于x = 0 To(UBound(PlateDef)) 'msg = Join(PlateDef(x),“,”)&vbCrLf&msg '下一个 “获得位置 y =(pos Mod 10) x =((pos-y)/ 10) GetPosInSrcRack = PlateDef(y)(x) 结束function
当然,这是有效的,但是很糟糕。
使用上面的公式,我会写:
函数GetPosInSrcRack(Pos) Pos =(((Pos MOD 10)-1)* 10)+(1 +((Pos - (Pos MOD 10))/ 10)) 结束function
但就像我说的,这还是不正确的(10给-8)有人可以帮我吗?
y=(MOD(x-1,10))*10+INT((x-1)/10)+1
(顺便说一句,你在做什么不是matrix换位,但是这只是做你所做的,只是更好。)
只需使用Paste Special > Transpose
选项。