messagebox problem

S

Sam

Hi,

I would like to be able to have my userform give back the
information message if there is already a value in the
destination saying -

"A2 already has a value! would you like
to replace " + x " with " y "?"

my code looks like this

- Set Rng = shData.Range("I" & Application.Match(CLng
(sh.Range("D6")), shData.Range("B:B"), 0))
Rng.Value = sh.Range("D8").Text

Thank you for your help
 
D

Dave Peterson

Dim Resp as long
....your declares
set rng = ....

resp = vbyes
if rng.value <> "" then
resp = msgbox("Overwrite " & rng.address(0,0) & ". It contains: " _
& rng.value, buttons:=vbyesno)
end if
if resp = vbyes then
rng.value = sh.Range("D8").Text
else
msgbox "come back later..."
end if
 

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

Top