Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The Conversation Pit > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
Thread Tools
Old 04-14-2008, 05:42 PM   #1 (permalink)
Registered User
 
Join Date: Apr 2008
Posts: 2
OS: Vista


Visual Basic HELP: Formula/lookup cell issues!

Hello all! I am having a problem with this picture insert code. It works great when you manually type in the picture name... but I am using a VLOOKUP to return the picture name from a control number. So, the first instance works... but then when I change the control number, and a new picture name appears in the cell (from VLOOKUP)... the picture doesn't change. I have to make the picture name call active and press enter for it to work..... how can I fix this? I want to just type the Control number, and everything recalcs... may just be a simple "Application.Volatile" issue.. but I don't know where to place it.... without it interfering.

Please help.

Private Sub Worksheet_Change(ByVal Target As Range)


Dim rng As Range
Dim rngProducts As Range
Dim pic As Picture, shp As Shape
Dim szInvalids As String

On Error Resume Next
'Only insert the picture if it's in the area where they type the Picture Names
'Change "C3:C25" to a range of cells where they'll be typing in Picture Names
Set rngProducts = Intersect(Me.Range("C3:C25"), Target)
On Error GoTo 0


If Not rngProducts Is Nothing Then 'They entered a picture name
'Loop through each cell they entered in
' in case they copied several picture names into several cells
For Each rng In rngProducts
'Remove the exisitng picture (shape) from the cell to the right
For Each shp In Me.Shapes
If shp.TopLeftCell.Address = rng.Offset(0, 1).Address Then shp.Delete
Next shp
'Insert the picture
On Error Resume Next
Set pic = ActiveSheet.Pictures.Insert("C:\Users\crt2\Desktop\Appeal\" & rng.Text & ".jpg")
On Error GoTo 0
If Not pic Is Nothing Then 'The picture exists
With pic
.Height = rng.Offset(0, 1).Height
.Width = rng.Offset(0, 1).Width
.Left = rng.Offset(0, 1).Left
.Top = rng.Offset(0, 1).Top
End With
Else 'Invalid entry, add it to the list of invalids szInvalids = szInvalids & rng.Address & ": " & rng.Text & vbLf
End If
Next rng


'Show them the invalid entries if there were any
If Len(szInvalids) Then
szInvalids = "The following were either invalid picture name entries 0r " & vbLf & "the image could not be found" & vbLf & vbLf & szInvalids
MsgBox szInvalids, vbExclamation
End If
End If
End Sub
dta180 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 04-14-2008, 06:00 PM   #2 (permalink)
Registered User
 
Join Date: Apr 2008
Posts: 2
OS: Vista


Re: Visual Basic HELP: Formula/lookup cell issues!

So, through some reading... I have figured out that the "Private Sub Worksheet_Change(ByVal Target As Range)" is causing my problem....

I know I won't be able to figure this out on my own.... just learning this stuff, any and all help will be much appreciated!
dta180 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 08:14 AM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82