Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba Excel中最后使用的列_Vba_Ms Access - Fatal编程技术网

Vba Excel中最后使用的列

Vba Excel中最后使用的列,vba,ms-access,Vba,Ms Access,我需要使用MS Access在代码中操作Excel工作表,并需要在打开的Excel文件中查找最后使用的列。我还需要在列中查找最后使用的行。以下是我正在使用的函数: 公共函数FindLastColumnInWSheetws作为工作表一样长 暗淡如长 变暗rng As范围 Set rng=ws.Cells.FindWhat:=*_ 之后:=ws.RangeA1_ 看:=xlPart_ LookIn:=xl公式_ SearchOrder:=xlByColumns_ 搜索方向:=xlPrevious_

我需要使用MS Access在代码中操作Excel工作表,并需要在打开的Excel文件中查找最后使用的列。我还需要在列中查找最后使用的行。

以下是我正在使用的函数:

公共函数FindLastColumnInWSheetws作为工作表一样长 暗淡如长 变暗rng As范围 Set rng=ws.Cells.FindWhat:=*_ 之后:=ws.RangeA1_ 看:=xlPart_ LookIn:=xl公式_ SearchOrder:=xlByColumns_ 搜索方向:=xlPrevious_ MatchCase:=假 如果rng不算什么,那么 LastCol=1 其他的 LastCol=rng.column 如果结束 FindLastColumnInWSheet=LastCol 端函数 公共函数FindAstrowinColumnWSheet作为工作表,columnName作为字符串作为整数 用wsheet FindLastRowInColumn=.RangecolumnName&.rows.Count.EndxlUp.row 以 端函数
到目前为止,您尝试了什么?您是否尝试过或查找过任何代码?如果是的话,你能在这里发帖吗?如果没有,请尝试搜索VBA代码以打开Excel并找到工作表中的最后一列,然后看看这是否适合您。@Marcucciboy2:谢谢您的回答您的问题并不适合这样做。当你在谷歌上搜索时,你会发现很多点击率,比如这一次,你还记得你从哪里找到代码的吗?我知道在这一点上,它是相当通用的,但我有一个可能是受与您相同的代码片段启发的,我想赞扬我所能找到的原始或最原始的版本我们正在我们的企业应用程序中使用此代码。我不知道是谁写的。