Asked by duncanb7
at 2024-10-25 02:04:33
Point:125 Replies:12 POST_ID:828391USER_ID:11059
Topic:
Visual Basic Programming;;Microsoft Excel Spreadsheet Software
I would like to ask a simple question about VBA 's range and cells usage
When I use range with cells syntax, it always occassionlly generate run-time
error but sometimes it is no problem and passed the VBA complier like the following
example,maxv = WorksheetFunction.Max(Range(Cells(firstrow, 29), Cells(lastrow, 29)))
Runtime is 400. When I change it to
maxv = WorksheetFunction.Max(Range(range("AB"& firstrow), range("AB"& lastrow))) that
is more stable and never report any error.
The question is the Range usage could not allow cells usage together or have some
condition like run in Sheet's sub instead of in Macro that is okay ?
The Range bug is hidden and sometimes has came out sometimes is not, Please advise
Duncan
When I use range with cells syntax, it always occassionlly generate run-time
error but sometimes it is no problem and passed the VBA complier like the following
example,maxv = WorksheetFunction.Max(Range(Cells(firstrow, 29), Cells(lastrow, 29)))
Runtime is 400. When I change it to
maxv = WorksheetFunction.Max(Range(range("AB"& firstrow), range("AB"& lastrow))) that
is more stable and never report any error.
The question is the Range usage could not allow cells usage together or have some
condition like run in Sheet's sub instead of in Macro that is okay ?
The Range bug is hidden and sometimes has came out sometimes is not, Please advise
Duncan