查找最后一列,然后找到该列中的最后一行 [英] Finding last column and then finding the last row in that column

查看:92
本文介绍了查找最后一列,然后找到该列中的最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在工作表中找到最后一列,然后在该特定列中找到最后一行.对于上一栏,我使用的是

I need to find the last column in a worksheet and then find the last row in that particular column. For last column I am using this:

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工作表上吗?

Can some also help me with putting all the data I want to save in an array 2 dimensional and then pasting the data on a Excel sheet?

推荐答案

方法如下:

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数组的方法:

Let's assume the batch data are sourced in Sheet1 beginning in cell A1, here is how to make the 2D array:

Dim myarray

myarray = Sheet1.[a1].CurrentRegion 

这篇关于查找最后一列,然后找到该列中的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆