Please help.. lost in code.

  • Thread starter Thread starter MarcB
  • Start date Start date
M

MarcB

Its doing something! But each time, no matter what, its entering th
"any text" statement into the field
 
I added target.row=1 and target.column=3 to validate that the cell bein
changed is c1, it might be different in you case.



other should be actually Other

Make sure that you identifying correct cell., other wise you wil
always get any text


try this code


Dim t As String
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pic As Object
Dim dat As String


If Target.Row = 1 And Target.Column = 3 Then


Sheets("Sheet1").Select
dat = ActiveSheet.Range("C1").Value

If dat = "other" Then
Sheets("Sheet2").Select
ActiveSheet.Range("C6").Select
ActiveSheet.Range("C6").Value = ""
Set pic = ActiveSheet.Pictures.Insert( _
"C:\Documents and Settings\Administrator\My Documents\M
Pictures\test.gif")
pic.Width = ActiveSheet.Range("C6").Width
pic.Height = ActiveSheet.Range("C6").Height
pic.Left = ActiveSheet.Range("C6").Left
pic.Top = ActiveSheet.Range("C6").Top
t = pic.Name
Application.CommandBars("Picture").Visible = False

Else
Sheets("Sheet2").Select
If t <> "" Then
ActiveSheet.Shapes(t).Select
ActiveSheet.Shapes(t).Delete
t = ""
End If

ActiveSheet.Range("C6").Select


ActiveSheet.Range("C6").Value = ""
ActiveSheet.Range("C6").Value = "any text"
End If

End If
End Su
 

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

Similar Threads


Back
Top