ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with some code (https://www.excelbanter.com/excel-programming/301544-help-some-code.html)

JayJay

help with some code
 
Hi i have a sheet and i want to write some VBA so i can check if some
values are present

data is for example

A
408
467
410

i want to check if the data in column A is in another list of data, if
so call some other function, if not another it all must be checked at
once as I will be attaching this to a command button


cheers in advance cos I know u guys/girls are helpfull :)




Frank Kabel

help with some code
 
Hi
try somtehing like the following (the list to be compared is in column
B):
sub foo()
dim t_rng as range
dim cell as range
dim s_rng as range
Dim ret_value

with activesheet
set t_rng=.range("B1:B100")
set s_rng = .range("A1:A10")
end with
for each cell in s_rng
ret_value=application.countif(t_rng,cell.value)
if ret_value0 then
exit for
end if
next

if ret_value0
'start one function
else
'another function call
end if
end sub


--
Regards
Frank Kabel
Frankfurt, Germany


JayJay wrote:
Hi i have a sheet and i want to write some VBA so i can check if some
values are present

data is for example

A
408
467
410

i want to check if the data in column A is in another list of data,

if
so call some other function, if not another it all must be checked at
once as I will be attaching this to a command button


cheers in advance cos I know u guys/girls are helpfull :)




All times are GMT +1. The time now is 08:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com