简体   繁体   English

检测Excel VBA中任何文件的单元格范围

[英]Detect cells range of any file in excel vba

I apologize if this is a stupid question but I can't get to figuring this one out. 如果这是一个愚蠢的问题,我深表歉意,但我无法解决这个问题。

What I want to do is import a .csv / .xlsx / .xls file and have a vba module auto-detect the range and do some cell formatting / apply filter etc. and eventually do a pivot. 我想做的是导入.csv / .xlsx / .xls文件,并使用vba模块自动检测范围,并执行一些单元格格式化/应用过滤器等操作,最后执行枢轴操作。

Any help will be appreciated😁 任何帮助将不胜感激😁

Gary's student is right. 加里的学生是对的。

Dim lRow as Long
Dim lCol as Long

lRow = ws.UsedRange.Rows.count
lCol = ws.UsedRange.Columns.count

Or 要么

Dim r As Range
r = ws.UsedRange

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM