ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_change (https://www.excelbanter.com/excel-programming/352085-worksheet_change.html)

Wayne

Worksheet_change
 
hi,
I need to execute code based on the value entered into a cell, actuall any
cel in a particular row. I have used the worksheet_change sub, and it works
just fine when one cell is changed.

But what if the user changes a range of cells -- e.g fill down or fill
right. how can I get the precise value changed in each cell as well as the
address.. I treid with target and .value but get errors ..

Also, I have if .column = 5 then... because I only care about column 'E'
however if the user choose cells D11:e:13 and fills down or right, the
..column is = 4 and never is = 5.

help


Bob Phillips[_6_]

Worksheet_change
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A5:M5"
Dim cell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
For Each cell In Intersect(Target, Me.Range(WS_RANGE))
cell.Font.Bold = True
Next cell
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"wAyne" wrote in message
...
hi,
I need to execute code based on the value entered into a cell, actuall any
cel in a particular row. I have used the worksheet_change sub, and it

works
just fine when one cell is changed.

But what if the user changes a range of cells -- e.g fill down or fill
right. how can I get the precise value changed in each cell as well as the
address.. I treid with target and .value but get errors ..

Also, I have if .column = 5 then... because I only care about column

'E'
however if the user choose cells D11:e:13 and fills down or right, the
.column is = 4 and never is = 5.

help




Wayne

Worksheet_change
 
Thanks bnob -- for each cell works great....

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A5:M5"
Dim cell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
For Each cell In Intersect(Target, Me.Range(WS_RANGE))
cell.Font.Bold = True
Next cell
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"wAyne" wrote in message
...
hi,
I need to execute code based on the value entered into a cell, actuall any
cel in a particular row. I have used the worksheet_change sub, and it

works
just fine when one cell is changed.

But what if the user changes a range of cells -- e.g fill down or fill
right. how can I get the precise value changed in each cell as well as the
address.. I treid with target and .value but get errors ..

Also, I have if .column = 5 then... because I only care about column

'E'
however if the user choose cells D11:e:13 and fills down or right, the
.column is = 4 and never is = 5.

help






All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com