Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL code need HELP

Status
Not open for further replies.

wuwang

Programmer
May 16, 2001
48
US
Hello,

The following code is to find the first row - last row and the first column - last column. It ran fine in EXCEL2000
but received error message in EXCEL 97.

The error message is :
"Run-time error '1004'
Unable to ge the CurrentReigon property of the Range class"

Could you help me to fix the problem?

Here is the code:

Private Sub cmd_Update_Click()
Dim ExpRang As Range

Set ExpRang = ActiveCell.CurrentRegion 'Error msg
here -- unable to get currentreigon
property of the RANGE class


FirstCol = ExpRang.Columns(1).Column
LastCol = FirstCol + ExpRang.Columns.Count - 1
FirstRow = ExpRang.Rows(1).Row
LastRow = FirstRow + ExpRang.Rows.Count - 1

Range("A1:A1").Select

.............................
 
Hi,
Do you have sheet protection on? If so, you cannot select ranges while a sheet is protected. Skip,
metzgsk@voughtaircraft.com
 
Hi Skip,

Thanks for your help. No, there is no sheet protection on.
Is there any other reason to cause this problem?
 
Golly, I have not idea. Are you running this from a button on a form? Skip,
metzgsk@voughtaircraft.com
 
Actually the button is set on a worksheet.

Paul
 
Looking at the couple of questions you have asked, Could I suggest that you work the other way around, that is write your code in Excel 97 VBA then use it with Excel 2000. The reason being Excel 2000 is backwards compatible (mostly) but you do not get forwards compatibility.

Chris
 
Let me ask in this way. How can we find the first row - last row and the first column - last column in EXCEL 97?
 
First/last Row/Column of a range?
Code:
With rng
   FirstRow = .Row
   LastRow = .Row + .Rows.Count -1
   First Col = .Column
   LastCol = .Column + .Columns.Count - 1
End With
Hope this helps :) Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top