簡體   English   中英

查找最后一列,然后找到該列中的最后一行

[英]Finding last column and then finding the last row in that column

我需要在工作表中找到最后一列,然后在該特定列中找到最后一行。 對於上一欄,我使用的是:

lastcol = .Cells(1, .Columns.count).End(xlToLeft).Column
last_row = Range((Cells(Rows.count), lastcol).Find("*", after:=r, LookIn:=x1values, lookat:=x1part, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

是工作表的快照:

在此處輸入圖片說明

有人還能幫我將要保存的所有數據放入二維數組中,然后將數據粘貼到Excel工作表上嗎?

方法如下:

lastcol = .Cells(1, .Columns.Count).End(xlToLeft).Column
lastrow = .Cells(.Rows.Count, lastcol).End(xlUp).Row

.Cells(lastrow + 1, lastcol).Resize(UBound(myarray)) = myarray

假設批處理數據從A1單元格的Sheet1中獲取,這是制作2D數組的方法:

Dim myarray

myarray = Sheet1.[a1].CurrentRegion 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM