Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Basic Stuff to some

Being a lerner at Vb, why do i get an error from the below ?

If the Combobox2.value = a value in Range(C159:C210) then i want a message to say so !!

Private Sub ComboBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng As Range
With Sheets("Scheduled In")
Set rng = Range("C159:C210")
If ComboBox2.Value = rng.Cells.Value Then '<== Error here
MsgBox "Already Used"
Else
MsgBox "Done"
End If
End With
End Sub


How do i write that line then?

CTM


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Basic Stuff to some

Private Sub ComboBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng As Range, res as variant
With Sheets("Scheduled In")
Set rng = .Range("C159:C210") ' <= include period
res = Application.Match(Combobox2.Value, rng,0)
If not iserror(res) Then '<== Error here
MsgBox "Already Used"
Else
MsgBox "Done"
End If
End With
End Sub

if Combobox2 contains a number then

res = Application.Match(cdbl(Combobox2.Value), rng,0)

the original causes a type mismatch error I suspect because you can't
compare a string to an array.

--
Regards,
Tom Ogilvy


"Corey" wrote in message
...
Being a lerner at Vb, why do i get an error from the below ?

If the Combobox2.value = a value in Range(C159:C210) then i want a message
to say so !!

Private Sub ComboBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng As Range
With Sheets("Scheduled In")
Set rng = Range("C159:C210")
If ComboBox2.Value = rng.Cells.Value Then '<== Error here
MsgBox "Already Used"
Else
MsgBox "Done"
End If
End With
End Sub


How do i write that line then?

CTM




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 help about some basic stuff Jumbala New Users to Excel 2 May 2nd 08 11:00 PM
SUM - IF formula, basic stuff I can't do! JS25 Excel Discussion (Misc queries) 2 December 1st 07 11:42 PM
Moving Rows (Basic VBA Stuff) None Excel Programming 5 December 22nd 06 01:16 AM
Basic Stuff. Sam Excel Programming 15 February 6th 04 04:31 PM
Highlight the bad stuff help!! John[_55_] Excel Programming 2 November 6th 03 08:58 PM


All times are GMT +1. The time now is 03:16 AM.

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

About Us

"It's about Microsoft Excel"