473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to loop through a column and highlight cells if not found in range

14
here is my code and what I am trying to do - I want to start at row 2 and for each value in column B see if that cell value exists in range B10000:B10100. If it does exist, then go to the next row and evaluate, if it doesnt exist then highlight that cell adn go to the next row and evaluate. do this until column B is empty. it is highlighting all rows, even those where the cell value is in that defined range. HELP and Thank you in advance

Option Explicit
Sub Crosscheck()

Dim x As Integer

'Application.ScreenUpdating = False
'Application.DisplayAlerts = False


x = 2
Do Until Cells(x + 1, 2).Value = ""
If Cells(x, 2).Value <> ("B10000:B10100") Then


Cells(x, 2).Select

Worksheets("investor file").Cells(x, 2).Interior.ColorIndex = 3
x = x + 1
Else
x = x + 1
End If

Loop

'Application.Quit
End Sub
Oct 27 '10 #1
4 2256
Guido Geurs
767 Expert 512MB
("B10000:B10100") has not the values of the range!
How to do:
Put the values from "B10000:B10100" in an array and check the values from B2... with the values in the array like:
Expand|Select|Wrap|Line Numbers
  1. For i =1 to ubound(array)
  2.   if Cells(x, 2).Value <> array(i) then
  3.   ..
  4.   else
  5.   ..
  6.   end if
  7. next
Oct 27 '10 #2
JonHuff
14
i am sorry but i am not an excel vba programmer - im used to access vba - you said

"for i=1 to ubound(array)"
"if cells(x,2).value <> array(i) then"

what do i use for "ubound(array)" and "array(i)"? - the more explicit you could be would help

i tried to Dim i as array - its not an option, so am I supposed to Dim i as Integer then what?
Oct 27 '10 #3
Guido Geurs
767 Expert 512MB
See attachment: run the macro.
Oct 27 '10 #4
JonHuff
14
thats it - thank you very much - if i were in belgium right now i'd buy you dinner - have a wonderful evening
Oct 27 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Daniel Chartier | last post by:
Hello, all. I found a bit of code that lets me read an Excel file from and to a specifi range. See the code below. But what if I only want to specify the STARTING position and simply want it...
0
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
1
by: Eric Martin | last post by:
Hello, Does anyone know of a way to loop thru a SQL table using code in a stored procedure? I need to go thru each record in a small table and build a string using values from the fields...
1
by: Jeremy Langworthy | last post by:
Hi I have a dynamicly generated form (well the elements are at least) that looks something like this: while( not end of returned records): <input name="plan_id" type="checkbox" id=""...
3
by: zxo102 | last post by:
Hi there, I need your help for python <--> excel. I want to paste selected cells (range) to different location on the same sheet in Excel through python. I have tried it for a while but could not...
4
by: Radu | last post by:
Hi. It seems to be very simple, actually, but I don't know if it is feasible in TSQL. I have a sproc which gathers in one place many calls to different other sprocs, all of them taking a...
1
by: Glen Vermeylen | last post by:
Hi, For a project at school we have to automate the assignment of seats in classrooms to students during the exams. The lady who previously did everything manually kept the layouts of the...
9
by: Bill Nguyen | last post by:
I need a VB routine to loop thru a select top folder to find all subfolders and list all subfolders/files under each of these subfolders. Any help is greatly appreciated. Bill
6
by: doncee | last post by:
Using a multi select list box to open several records in a pre - defined form. Most of the code that follows is taken from a posting by Alan Browne on his web site. The click routine is supposed...
0
by: rdemyan via AccessMonster.com | last post by:
I have a need to highlight a date range in a bar chart. If the "highlighting" is accomplished by changing the bar column color for the specific months in the date range, that would be great. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.