Excel VBA-选择范围以最后完全空白的行 [英] Excel VBA - selecting range to last completely blank row

查看:77
本文介绍了Excel VBA-选择范围以最后完全空白的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些VBA代码,需要选择从A84到X的范围.我正在使用此代码选择该范围到数据的最后一行.

I have some VBA code that needs to select a range from A84 to X. I'm using this code to select that range to the last row in the data.

Dim Lastrow As Integer
Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

Range("A84:X" & Lastrow).Select

此行在第一列中的A列中带有空白单元格处停止.我需要它来检查A到Z列,而不只是A列.例如,如果A列中的第84至94行有一个值,但对于95行,则F或R列中只有数据,它将不包括第95行.如何查看A:Z列以确定行是否为空白?

This stops at the first row with a blank cell in the A column. I need it to check columns A through Z, not just A. For example, if there is a value in column A on rows 84 to 94, but for row 95, there's only data in column F or R, it won't include row 95. How can this look at columns A:Z to determine whether or not the row is blank?

推荐答案

只需将 Lastrow 设置为

Lastrow = Range("A:Z").Find("*", , , , xlByRows, xlPrevious).Row

这篇关于Excel VBA-选择范围以最后完全空白的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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