find number<> and insert "Y"

markdoughty

Board Regular
Joined
Nov 4, 2010
Messages
226
Im trying to get the code below to select a sheet, find a value <> to the value of a combobox (cbosalesordernumber1), offsett by 7 and insert a "Y".

I had this working at one point but it has now stopped inserting the "Y"

Any help appreciated.

HTML:
Private Sub closeorder_Click()
If MsgBox("Closing This Order Will Mean No Further Additions / Alerations Will Be Able.", vbOKCancel, _"Close Order") = vbCancel ThenCall UserForm_Initialize
Else: GoTo closeorder:
closeorder:ActiveWorkbook.Sheets("Sales Entry").Activate    
Range("a1").Select        
Do        If ActiveCell.Value < cbosalesordernumber1 = False Then        
ActiveCell.Offset(1, 0).Select 
End If    
Loop Until (ActiveCell) <> cbosalesordernumber = True        
With ActiveCell.Select    
ActiveCell.Offset(0, 7) = "Y"    

If MsgBox("Returning To Sales Counter Menu", vbOKOnly, "Return To Sales Counter Menu") = vbOK Then
Unload Me
SimpleSheet.salescountermenu.Show


End If
End With
End If
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi, maybe after the range("a1").select also put a .activate
ie:
Rich (BB code):
closeorder:ActiveWorkbook.Sheets("Sales Entry").Activate    
Range("a1").Select 
Range("a1").activate       
Do        If ActiveCell.Value < cbosalesordernumber1 = False Then        
ActiveCell.Offset(1, 0).Select 
 
Upvote 0
No this does`nt help im afraid.

However, i have now found that my original code is working to a point.

The code activates the sheet, selects the range as required, but then fails to loop to find a matching value, it put the value in the right cell, but in the first row checked?

Does this mean my"<" and "<>" are all incorrect?

Mark
 
Upvote 0
I have now got my code as below. All appears to work, no errors notified, only the code is not looping to find the code that is "<>" ( Im working on the basis this means "the same as / equal too").


Instead it selects A1 and drops the "Y" into cell offsett 7 of Row A.


HTML:
Private Sub closeorder_Click()
If MsgBox("Closing This Order Will Mean No Further Additions / Alerations Will Be Able.", vbOKCancel, _"Close Order") = vbCancel ThenCall UserForm_Initialize
Else: GoTo closeorder:
closeorder:ActiveWorkbook.Sheets("Sales Entry").Activate    Range("a1").Select        Do        If ActiveCell.Value <> cbosalesordernumber.Value = False Then        ActiveCell.Offset(1, 0).Select    End If    Loop Until ActiveCell.Value <> cbosalesordernumber.Value = True        With ActiveCell.Select    ActiveCell.Offset(0, 7) = "Y"    If MsgBox("Returning To Sales Counter Menu", vbOKOnly, "Return To Sales Counter Menu") = vbOK ThenUnload MeSimpleSheet.salescountermenu.Show


End IfEnd WithEnd If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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