-
This is turning the entered data into text in the format March 07 (7th March)
[VBA]
Me.ComboBox2.Value = Format(ComboBox2.Value, "mmmm dd")
[/VBA]
Column 1 (why are you searching all cells?) contains date values, shown in the format Mar-07 (March 2007)
Not surprisingly, nothing is found hence the error.
-
Firstly Paul Hunt doesn't exist for that combination, secondly the code was only for the worksheet that the button resided on, thirdly your second sheet was protected!
This code will do what you need, provided sheet1 is still in place with the names.
[VBA]
Private Sub CommandButton1_Click()
Dim Sht As Worksheet
Dim rFound As Range, dFound As Range
Dim rRow As Long, dCol As Long
Dim Rng As Range
Dim OriginalSheet As String
OriginalSheet = ActiveSheet.Name
Me.ComboBox2.Value = Format(ComboBox2.Value, "mmmm dd")
Application.ScreenUpdating = False
For Each Sht In Sheets
Sht.Select
Sht.Unprotect
If Sht.Name = "Sheet1" Then GoTo Nxt
On Error Resume Next
Set dFound = Cells.Find(What:=Me.ComboBox2.Value, After:=Range("C22"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
On Error GoTo 0
If Not dFound Is Nothing Then
dCol = dFound.Column
Else
MsgBox "Date Not Found on Sheet " & Sht.Name
GoTo Nxt
End If
On Error Resume Next
Set rFound = Range("C22:C" & Range("C" & Rows.Count).End(xlUp).Row).Find(What:=Me.ComboBox1.Value, _
After:=Range("C22"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
On Error GoTo 0
If Not rFound Is Nothing Then
rRow = rFound.Row
Else
MsgBox "Name Not Found On Sheet " & Sht.Name
GoTo Nxt
End If
Cells(rRow, dCol).Value = "Recieved"
Nxt:
Sht.Protect
Next Sht
Sheets(OriginalSheet).Activate
Application.ScreenUpdating = True
Unload Me
End Sub
[/VBA]
-
Simon, you are a genius!
It works great now, but only when I actually enter 'april 1st' into the combo box instead of 01/04/2008? This is not a problem.
Just a couple of more things, how can I get the program to enter a GREEN background when it adds the white received text?
Also, how do I get rid of that sheet protection code if I need to?
Thanks again, I appreciate all you time and effort and I can only hope to be as proficient as you in these skills, one
-
Actually that code doesn't work well, swap it for this:
[VBA]
Private Sub commandbutton1_click()
Dim Sht As Worksheet
Dim rFound As Range, dFound As Range
Dim rRow As Long, dCol As Long
Dim Rng As Range
Dim OriginalSheet As String
OriginalSheet = ActiveSheet.Name
Me.ComboBox2.Value = Format(ComboBox2.Value, "mmmm dd")
Application.ScreenUpdating = False
For Each Sht In Sheets
Sht.Select
Sht.Unprotect
If Sht.Name = "Sheet1" Then GoTo Nxt
On Error Resume Next
Set dFound = Cells.Find(What:=Me.ComboBox2.Value, After:=Range("C22"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
On Error GoTo 0
If Not dFound Is Nothing Then
dCol = dFound.Column
Else
MsgBox "Date Not Found on Sheet " & Sht.Name
GoTo Nxt
End If
On Error Resume Next
Set rFound = Range("C" & dFound.Row - 1 & ":C" & Range("C" & Rows.Count).End(xlUp).Row).Find(What:=Me.ComboBox1.Value, _
After:=Range("C" & dFound.Row - 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
On Error GoTo 0
If Not rFound Is Nothing Then
rRow = rFound.Row
Else
MsgBox "Name Not Found On Sheet " & Sht.Name
GoTo Nxt
End If
Cells(rRow, dCol).Value = "Recieved"
Cells(rRow, dCol).Interior.ColorIndex = 4
Nxt:
Sht.Protect
Next Sht
Sheets(OriginalSheet).Activate
Application.ScreenUpdating = True
Unload Me
End Sub
[/VBA]Ive added changing the cell to green but you might want to change the number for a darker green!
Protection code: just remove it from top and bottom of my code (as that is where it is now handled) then go to each sheet and click on unprotect before running the code again!
-
Hi Simon,
Sorry to bother you again, but try 'Mick Burrows' july 6th 2008, for some reason it does not add a 'received?
Thanks.
Sorry it works with your new code.
-
Hi again Simon,
What's your experience with Visual Studio 2008?
I have created and Excel Addin with an Office Ribbon and a button on it.
I want to click that button on the ribbon and launch the Tracker form you helped me with, but I don't know the code within Visual Studio 2008 to execute that.
Any thoughts?
Thanks.
-
I have it but never even opened it! you should start a new thread though!