Changed cell row number...

  • Thread starter Thread starter Sridhar Pentlavalli via OfficeKB.com
  • Start date Start date
S

Sridhar Pentlavalli via OfficeKB.com

Hi

I have a requirement in which I am getting some problem. Lets say I have four columns in a sheet. If first three columns are entered with some values, I need to compute some thing and put it in fourth column. For that purpose I am using "Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)" function. Here the problem I am facing is, in this function, how to get the row number in which the data has been changed?

If I am not clear, let me explain clearly. If data in cells(3,1), cells(3,2) and cells(3,3) is changed, then I need to compute some thing and put it in cells(3,4). Here how to trap the row number as 3 in side the "Workbook_SheetChange" function.

Thanks in advance
 
The Target parameter is a range object, so you can look at
Target.Row
to get the row.

Couple of things to watch for:
1. Target can (I think) be a multi-cell range so you will need to
iterate through the range to make sure you catch all changed rows
2. If you make a change in the SheetChange code then this will in turn
trigger your code again and so on.... You can temporarily disable
events using
Application.eneableevents=false
to prevent this.

Tim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top