单元格A1
左上角坐标,A2
右下角坐标,我如何让A3
以csv格式显示该框的所有坐标?< / p>
例如:
Cell A1 = (24,20)
Cell A2 = (26,19)
如何获得这个?:
Cell A3 = (24,20),(25,20),(26,20),(24,19),(25,19),(26,19)
我正在使用Excel 2011
答案 0 :(得分:0)
这是你在尝试什么? (我希望我已正确理解您的查询。如果没有,请随时纠正我)
将此代码粘贴到模块中,然后调用单元格=GetCord(A1,A2)
中的A3
,如下面的屏幕截图所示。
Public Function GetCord(rng1 As Range, rng2 As Range) As String
Dim strTmp As String, strTmp1 As String, strTmp2 As String
Dim a As Long, b As Long, i As Long, j As Long, k As Long
strTmp1 = rng1.Value: strTmp2 = rng2.Value
strTmp1 = Trim(Replace(strTmp1, "(", ""))
strTmp1 = Trim(Replace(strTmp1, ")", ""))
strTmp2 = Trim(Replace(strTmp2, "(", ""))
strTmp2 = Trim(Replace(strTmp2, ")", ""))
i = Val(Split(strTmp1, ",")(0))
j = Val(Split(strTmp1, ",")(1))
k = Val(Split(strTmp2, ",")(0))
l = Val(Split(strTmp2, ",")(1))
For b = j To l Step -1
For a = i To k
strTmp = strTmp & "(" & a & "," & b & "),"
Next a
Next b
GetCord = Left(strTmp, Len(strTmp) - 1)
End Function
<强>截图强>
注意:上述函数假设y
Co-Ordinates按降序排列。为了满足所有场景,您必须在该功能中包含该检查。