Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default cant compare cells with numbers in them??


I am having trouble comparing a cell that contains a number against what
the user enters into a form cell. the code i have works for letters or a
combination of letters and numbers, but not numbers on their own??

I have set the variable as a String and the cells format as text, i
have also tried the cell format as general.

here is my code, i have highlight the bit where it assigns the value
from the sheet to the variable i want.


blnvalidCode = False
blnvalidCode2 = False
blnvalidCode3 = False

For j = 5 To 500

If staff_name = Worksheets("Project Codes & Staff
Names").Cells(j, 6).Value Then

For i = 5 To 500
blnvalidCode2 = True
If proj_code = Worksheets("Project Codes & Staff
Names").Cells(i, 4).Value Then
For k = 5 To 500
blnvalidCode = True
If staff_id = Worksheets("Project Codes & Staff
Names").Cells(k, 2) Then

****this is the part where it puts blank into staff_id and therefore
blnvalidCode3 stays as FALSE. ****

Call data_entry
blnvalidCode3 = True
Exit For
End If

Next k
If blnvalidCode3 = False Then
MsgBox (Worksheets("Project Codes & Staff
Names").Cells(k, 2))
MsgBox "Please enter a valid Staff ID", vbExclamation +
vbOKOnly, "Invalid Staff ID Error"

Worksheets("Record Names").Protect Password:="poker"
End If

Exit For
End If

Next i

If blnvalidCode = False Then
MsgBox "Please enter a valid Project Code",
vbExclamation + vbOKOnly, "Invalid Project Code Error"
Worksheets("Record Names").Protect Password:="poker"
End If

Exit For
End If

Next j

If blnvalidCode2 = False Then
MsgBox "Please enter a valid team member's name!",
vbExclamation + vbOKOnly, "Invalid Team Name Error"
Worksheets("Record Names").Protect Password:="poker"
End If

End If

End Sub



All help would be appreciated

Thanks

Andy


--
Andyd74
------------------------------------------------------------------------
Andyd74's Profile: http://www.excelforum.com/member.php...o&userid=34013
View this thread: http://www.excelforum.com/showthread...hreadid=541587

  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default cant compare cells with numbers in them??

I think I understand your issue. Try this:

staff_id = CStr(Worksheets("Project Codes & Staff
Names").Cells(k, 2))

--
Hmm...they have the Internet on COMPUTERS now!


"Andyd74" wrote:


I am having trouble comparing a cell that contains a number against what
the user enters into a form cell. the code i have works for letters or a
combination of letters and numbers, but not numbers on their own??

I have set the variable as a String and the cells format as text, i
have also tried the cell format as general.

here is my code, i have highlight the bit where it assigns the value
from the sheet to the variable i want.


blnvalidCode = False
blnvalidCode2 = False
blnvalidCode3 = False

For j = 5 To 500

If staff_name = Worksheets("Project Codes & Staff
Names").Cells(j, 6).Value Then

For i = 5 To 500
blnvalidCode2 = True
If proj_code = Worksheets("Project Codes & Staff
Names").Cells(i, 4).Value Then
For k = 5 To 500
blnvalidCode = True
If staff_id = Worksheets("Project Codes & Staff
Names").Cells(k, 2) Then

****this is the part where it puts blank into staff_id and therefore
blnvalidCode3 stays as FALSE. ****

Call data_entry
blnvalidCode3 = True
Exit For
End If

Next k
If blnvalidCode3 = False Then
MsgBox (Worksheets("Project Codes & Staff
Names").Cells(k, 2))
MsgBox "Please enter a valid Staff ID", vbExclamation +
vbOKOnly, "Invalid Staff ID Error"

Worksheets("Record Names").Protect Password:="poker"
End If

Exit For
End If

Next i

If blnvalidCode = False Then
MsgBox "Please enter a valid Project Code",
vbExclamation + vbOKOnly, "Invalid Project Code Error"
Worksheets("Record Names").Protect Password:="poker"
End If

Exit For
End If

Next j

If blnvalidCode2 = False Then
MsgBox "Please enter a valid team member's name!",
vbExclamation + vbOKOnly, "Invalid Team Name Error"
Worksheets("Record Names").Protect Password:="poker"
End If

End If

End Sub



All help would be appreciated

Thanks

Andy


--
Andyd74
------------------------------------------------------------------------
Andyd74's Profile: http://www.excelforum.com/member.php...o&userid=34013
View this thread: http://www.excelforum.com/showthread...hreadid=541587


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to compare two lists and identify cells with same numbers in Bockhamptoner Excel Discussion (Misc queries) 8 September 11th 08 11:34 AM
VLOOKUP should compare numbers stored as text to plain numbers. VLOOKUP - Numbers stored as text Excel Worksheet Functions 0 March 31st 06 05:53 PM
How do I compare cells and if FALSE compare to next cell in EXCEL Cindie Excel Worksheet Functions 0 March 24th 06 05:29 PM
How do i compare numbers in cells with formula nolechik Excel Discussion (Misc queries) 3 November 18th 05 07:57 PM
How to compare two cells for the same numbers sun1x Excel Worksheet Functions 13 October 27th 05 02:55 PM


All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"