View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
external usenet poster
 
Posts: 138
Default ActiveCell changes contents of TextBox

This should do what you want but the sub will run EVERY TIME you select
a new cell.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)

dim mymsg as string

if ActiveCell.Address="A1" then
mymsg="String 1"
elseif activecell.address="A6" then
mymsg="String 2"
else
exit sub
end if

msgbox mymsg

End Sub


wrote:
I have on a worksheet a textbox, and i want its contents to change
depending on the highlighted cell.

For example:

when A1 is selected the textbox contents are "msg1"

when A6 is selected the textbox reads "msg2"

Thanks in advance.
Nick