vbOKCancel code will not work

ejs7597

New Member
Joined
Sep 25, 2006
Messages
35
I have some simple code that is causing me to pull out my hair.
All it does is check to see if the value in cell "AK" & i (i being equeal to the active cell row, =1. This part is working, if the value is = to 1 then the msg box pops up, allowing me to choose, Yes or No. I have told it if
vbYes then put the text "yes" in a cell. The problem is that if, I click yes, it does nothing, and yes or no msg box will not go away. If I click no, then it puts "yes" in the cell I requested and the msg box goes away. I can click the Yes button forever, but it will not go away. It is like it is stuck in a loop or something. Any help would be appreciated. I have also tried putting different values into the cell, ex: other text or numbers.

Thanks

Private Sub Worksheet_Change(ByVal Target As Range)

i = ActiveCell.Row

If Range("AK" & i) = 1 Then

Dim myLabel

myLabel = MsgBox("Do you need a BARCODE LABEL", vbYesNo)

If myLabel = vbYes Then
Range("AL" & i) = "yes"

End If

End If


End Sub
 

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.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I assume you mean Target.row not Activecell.Row ?

This could be limited to only run when you are changing values in certain ranges if you want, but, perhaps:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myLabel As Long
i = Target.Row
If Range("AK" & i) = 1 Then
    Application.EnableEvents = False
        myLabel = MsgBox("Do you need a BARCODE LABEL", vbYesNo)
        If myLabel = vbYes Then Range("AL" & i) = "yes"
    Application.EnableEvents = True
End If
End Sub
 

Forum statistics

Threads
1,136,926
Messages
5,678,604
Members
419,774
Latest member
MooseWinooski

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
Top