在Excel表中找到最后一个单元格?

编程入门 行业动态 更新时间:2024-10-25 04:19:32
本文介绍了在Excel表中找到最后一个单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用vb6并将数据复制到Excel表格中。我需要做的是将数据附加到现有工作表。我正在找到我需要找到工作表中最后一个单元格的索引号(只有一个工作表)。我已经尝试了几个东西,如 oBook.range.cells.specialcells(xllastcell )但无济于事。我现在打开我想要的工作表是这个

I'm using vb6 and copying data to an excel sheet. What I need to do is append data to an existing sheet. I am at the point where I need to find the index number of the last cell in the sheet (there's only one sheet.) I've tried a couple things like oBook.range.cells.specialcells(xllastcell) but to no avail. What I have right now to open the worksheet I want is this

If Not Dir(strPath) = "" Then Set oExcel = CreateObject("Excel.application") Set oBook = oExcel.workbooks.open(strPath)

但我不知道从这里做什么来找到工作簿中的最后一个单元格。

but I have no idea what to do from here to find the last cell in the workbook.

推荐答案

在互联网冲浪的答案我发现一行代码工作。我必须将一些值,例如 xlbyrows 更改为1和 xlprevious 为2,因为vb6 dows

Upon scouring the internet for the answer I found a line of code that worked. I had to change some of the values such as xlbyrows to "1" and xlprevious to "2" because vb6 dows not recognize the terms but can use the number constants.

这是代码的原始代码

LastRow = Cells.Find("*",SearchOrder:=xlByRows,SearchDirection:=xlPrevious).Row

这是我改变了它与我的代码一起使用

this is what I changed it to that worked with my code

iCell = oExcel.cells.find("*", searchorder:=1, searchdirection:=2).row

更多推荐

在Excel表中找到最后一个单元格?

本文发布于:2023-10-28 00:52:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535018.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   中找到   Excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!