ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell change (https://www.excelbanter.com/excel-programming/280241-cell-change.html)

lars kofod

Cell change
 
I'm kinda new to excel vba. I'm trying to make excel
launch a sub when a cell i a range is changed.

code as of now:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

'StrOmraarde$ = "e16:e1000"

Adresse$ = "$E$25,$E$40"
If Target.Count 1 Then Exit Sub
If Target.Address = "$F$25" Then
MsgBox ("test1")
Else
MsgBox ("test2")

End If

End Sub

This works fine, but I need address to be a range
ie. "E16,E55".

How do I do that??

Thanks
Lars Kofod

Tom Ogilvy

Cell change
 
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

'StrOmraarde$ = "e16:e1000"

Adresse$ = "$E$25,$E$40"
If Target.Count 1 Then Exit Sub
If not intersect(Target,Range("E25:E40")) Then
MsgBox ("test1")
Else
MsgBox ("test2")

End If

End Sub

If you really mean just the two cells E25 and E40, then change it to

intersect(Target,Range("E24,E40"))

--
Regards,
Tom Ogilvy


"lars kofod" wrote in message
...
I'm kinda new to excel vba. I'm trying to make excel
launch a sub when a cell i a range is changed.

code as of now:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

'StrOmraarde$ = "e16:e1000"

Adresse$ = "$E$25,$E$40"
If Target.Count 1 Then Exit Sub
If Target.Address = "$F$25" Then
MsgBox ("test1")
Else
MsgBox ("test2")

End If

End Sub

This works fine, but I need address to be a range
ie. "E16,E55".

How do I do that??

Thanks
Lars Kofod





All times are GMT +1. The time now is 05:07 PM.

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