Code not working as it should

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Im using a basic code to advise me which label to be applied to a parcel.
I type a country into a cell then the code looks up a worksheet where next to that countries name are only 2 options.
One column is ITAS and the other is ISF,one cell will be empty and the other will have a tick in it.

Last few days at the post office ive been advised that the parcel has the wrong label on it.
My photo example shows the sheet where the code looks at.

As you can see ITALY would have a label ITAS but when i start to type this into the cell i am told to use ISF.
MOVING THE TICK FROM ONE CELL TO THE OTHER ON THE DATA SHEET MADE NO DIFFERENCE.

Hence why im stuck.


The code in use is shown below.

Code:
Private Sub ComboBox1_Change()    Dim vLkup As Variant
    
        With ThisWorkbook.Worksheets("INFO")
        vLkup = Application.Match(ComboBox1.Text, .Range("AI2:AI236"), 0)
        If Not IsError(vLkup) Then
        If .Cells(vLkup + 2, "AJ").Value <> "" Then TextBox1.Text = "INTERNATIONAL TRACK & SIGNED"
        If .Cells(vLkup + 2, "AK").Value <> "" Then TextBox1.Text = "INTERNATIONAL SIGNED FOR"
    End If
End With
End Sub


Private Sub TextBox1_Change()
If (Me.TextBox1.Value) = "INTERNATIONAL SIGNED FOR" Then
   Me.LabelBox.Picture = LoadPicture(ThisWorkbook.Path & "\isf.jpg")
ElseIf (Me.TextBox1.Value) = "INTERNATIONAL TRACK & SIGNED" Then
   Me.LabelBox.Picture = LoadPicture(ThisWorkbook.Path & "\itas.jpg")
   End If
End Sub

LABELS.jpg
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Change the tick in Ivory Coast then put Italy in the Combobox1. Does it change the picture? You will have to re enter Italy as that is the trigger to fire the macros. If so change the vLkup + 2 to say vLkup + 1.
 
Upvote 0
Changed Ivory coast and then Italy did change the photo.
Ive now changed +2 to +1 and it was ok.

Tomorrow i will check the whole list.
Many thanks so far.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,052
Latest member
Fuddy_Duddy

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