Msgbox question

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,737
Office Version
  1. 2007
Platform
  1. Windows
Please can you advise how to re-arrange the way the msg text is shown.

The current code in use is shown below which reads "33 Photo Doesn`t Exist"

I would like to have it read "Photo 33 Doesn`t Exist"

Code:
MsgBox Target.Value & " Photo Doesn't exist! ", vbCritical, "No Photo Found"
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Just add another literal string to your concatenation and change the order, i.e.
Code:
MsgBox "Photo " & Target.Value & " Doesn't exist!"
 
Upvote 0
Thanks,
I didnt put the " before the &

I have added a yes no to this msg box as now shown in the code below but can you advise please when YES is clicked the folder is open,here is the path C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\


Code:
Private Sub Worksheet_Change(ByVal Target As Range)Dim shp As Shape
If Intersect(Target, [A:A]) Is Nothing Then Exit Sub
If Target.Row Mod 20 = 0 Then Exit Sub
On Error GoTo son


For Each shp In ActiveSheet.Shapes
If shp.Type = msoPicture And shp.TopLeftCell.Address = Target.Offset(0, 1).Address Then shp.Delete
Next


If Target.Value <> "" And Dir("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\" & "\" & Target.Value & ".jpg") = "" Then
        'picture not there!
         MsgBox "Photo " & Target.Value & " Doesn't exist" & vbCrLf & "Open The Picture Folder ?", vbCritical + vbYesNo, "No Photo Found"
         Exit Sub
End If


ActiveSheet.Pictures.Insert("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\" & "\" & Target.Value & ".jpg").Select
Selection.Top = Target.Offset(0, 1).Top + 5
Selection.Left = Target.Offset(0, 1).Left + 5


With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Height = Target.Offset(0, 1).Height - 10
.Width = Target.Offset(0, 1).Width - 10
End With
Target.Offset(1, 0).Select
son:


End Sub
 
Upvote 0
I have added a yes no to this msg box as now shown in the code below but can you advise please when YES is clicked the folder is open,here is the path C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME\
This looks like a completely different question that the first one you asked (and we resolved).
As such, it should be posted in a new thread, especially since I do not understand the question any probably cannot help you with that.

One other note, I think I see a potential error in one of your lines:
Code:
If Target.Value <> "" And Dir("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME[COLOR=#ff0000]\" & "\" [/COLOR]& Target.Value & ".jpg") = "" Then
Not sure why you have it written like that, as that will return two back slashes in a row, which I doubt is what you want.
I think you want to get rid of the:
Code:
[B] & "\"[/B]
 
Last edited:
Upvote 0
Hi,
Can you advise where i would see these 2 back slashes as currently i dont ?
 
Upvote 0
This:
Code:
[COLOR=#333333][FONT=monospace]If Target.Value <> "" And Dir("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME[/FONT][/COLOR][COLOR=#ff0000][FONT=monospace]\" & "\" [/FONT][/COLOR][COLOR=#333333][FONT=monospace]& Target.Value & ".jpg") = "" Then[/FONT][/COLOR]
should probably be:
Code:
[COLOR=#333333][FONT=monospace]If Target.Value <> "" And Dir("C:\Users\Ian\Desktop\SKYPE\LOCK PICK ME[/FONT][/COLOR][COLOR=#ff0000][FONT=monospace]\" [/FONT][/COLOR][COLOR=#333333][FONT=monospace]& Target.Value & ".jpg") = "" Then[/FONT][/COLOR]
Otherwise you have two backslashes in a row.
 
Last edited:
Upvote 0
Sorry i did see them in that line of code but where would i see them return 2 back slashes on my sheet,then as i currently dont ?
 
Upvote 0
That line doesn't return anything to the sheet. It just checks to see if that file exists.
Because there are two backslashes in a row, it will probably never find it, even if it does exist, because it will be looking in the wrong place (unless it is smart enough to resolve a double backslash - I don't know, you would need to test it).
 
Upvote 0
Ok
Didn’t make my difference if there or not so removed.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top