Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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

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
Simple IF problem Old Timer Excel Discussion (Misc queries) 1 November 7th 06 02:11 AM
Mail Merging Dates from Excel - Word Simple Problem! CFD Excel Discussion (Misc queries) 1 July 13th 06 01:08 AM
Simple problem excelnovice1 New Users to Excel 3 June 29th 06 11:19 AM
Problem with Excel: Simple multiplying calculations don't work. dforty3 Excel Discussion (Misc queries) 3 July 22nd 05 05:47 PM
i've got a simple excel problem that needs solving... Massive Excel Discussion (Misc queries) 6 May 16th 05 08:46 AM


All times are GMT +1. The time now is 09:47 AM.

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"