我正在Access中处理Excel电子表格,并使用下面列出的代码将Excel列字母转换为数字。 ColRef
的值为"F"
。使用完全相同的输入和过程运行功能有时会导致
“远程服务器计算机不存在或不可用”错误
有时它给出正确的结果6。
非常感谢您提供的帮助。
' The function below converts a column reference (A - IV) to a column number between 1 and 256:
Public Function ColRef2ColNo(ColRef As String) As Integer
ColRef2ColNo = 0
On Error Resume Next
ColRef2ColNo = Range(ColRef & "1").Column
End Function