![]() |
Simple Excel VB problem
Hi, im very new to Visual Basic and am using it for a university
project im doing. i want to be able to check if an integer within a cell is in a range of cells on a different sheet also containing integers. If it is in that range of cells then i want it to publish to a list box i have. Im guessing this is a real simple bit of syntax so if anyone could give me some example ccode, i would be very much appreciative. Many thanks, Kieran |
Simple Excel VB problem
The easiest way that I can think of is to use a worksheet function to check
if that value is found in the other range. COUNTIF will count how many times it appears. You can use a worksheet function in VBA using the WorksheetFunction method, and if the value is greater than 0 you know its there, so add it to the listbox. As it is a uni project I will leave you to look up the details, I have given you a method. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ups.com... Hi, im very new to Visual Basic and am using it for a university project im doing. i want to be able to check if an integer within a cell is in a range of cells on a different sheet also containing integers. If it is in that range of cells then i want it to publish to a list box i have. Im guessing this is a real simple bit of syntax so if anyone could give me some example ccode, i would be very much appreciative. Many thanks, Kieran |
Simple Excel VB problem
Thank you very much Bob, that has helped greatly, problem solved.
Kieran On Mar 27, 10:48 am, "Bob Phillips" wrote: The easiest way that I can think of is to use a worksheet function to check if that value is found in the other range. COUNTIF will count how many times it appears. You can use a worksheet function in VBA using the WorksheetFunction method, and if the value is greater than 0 you know its there, so add it to the listbox. As it is a uni project I will leave you to look up the details, I have given you a method. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ups.com... Hi, im very new to Visual Basic and am using it for a university project im doing. i want to be able to check if an integer within a cell is in a range of cells on a different sheet also containing integers. If it is in that range of cells then i want it to publish to a list box i have. Im guessing this is a real simple bit of syntax so if anyone could give me some example ccode, i would be very much appreciative. Many thanks, Kieran |
Simple Excel VB problem
Sub elkw()
v = Sheets("s1").Range("A1").Value Set r2 = Sheets("s2").Range("A1:B9") k = Application.CountIf(r2, v) If k 0 Then MsgBox (v & " is there") Else MsgBox (v & " is not there") End If End Sub Gets a value from sheet s1 and looks for it in a range of cells in sheet s2 -- Gary''s Student gsnu200712 |
All times are GMT +1. The time now is 07:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com