update details using vba

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a validation list over 2 cells which when a specific word is selected
from the list then I need the word 'Please specify:' to be shown in another
cell but when any other word is selected from the list is is empty then I
dont want the 'Please specify:' to be visible.

Can anyone help.

I have tried the following but does not work and I dont know why.

Private Sub Worksheet_selectionChange(ByVal Target As Range)

If Target.Address = "G26" Then
If Range("G26").Value = "Other" Then
Range("E28").Value = "Please specify:"
Else
Range("E28").Value = ""
End If
End If

End Sub

Thanks
Noemi
 
Hi Noemi

Try:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$G$26" Then

If Range("G26").Value = "Other" Then
Range("E28").Value = "Please specify:"
Else
Range("E28").Value = ""
End If
End If


End Sub

Regards
Shaun
 
Works on my computer. But Shaun, why must the address be "$G$26" and can't
be simply "G26"?

Thanks!
 
The .address property has an option that allows you to include those dollar
signs or not.

If you don't want them:
if Target.Address(rowabsolute:=False, columnabsolute:=False) = "G26" then

or simply:
if Target.Address(0,0) = "G26" then

(False and 0 will be treated the same)
 
Dave,

Many thanks for the explanation!

Dave Peterson said:
The .address property has an option that allows you to include those dollar
signs or not.

If you don't want them:
if Target.Address(rowabsolute:=False, columnabsolute:=False) = "G26" then

or simply:
if Target.Address(0,0) = "G26" then

(False and 0 will be treated the same)
 

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