简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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