Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cycle through each row and look for string in each cell


Hi there,

I need to cycle through every row of data, look in column A and find i
the string "Total" exists in the cell.
the string will be part of another string. e.g. "D01234-A Total".

Every instance that is found of a cell in column A containing Total
eill require the entire row to be made 'Bold' font.

does this sound do-able?

--
matp
-----------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=51310

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cycle through each row and look for string in each cell


Hi pal,

This is the code to search through all your values in your cells;

Code:
--------------------

i = 1:
Do
If InStr(1, Cells(i, 1).Value, "Total", vbTextCompare) < 0 Then
'change cell colour code here
End If
i = i + 1
Loop Until Cells(i, 1).Value = ""

--------------------


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513103

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cycle through each row and look for string in each cell


hi,

thanks for the code!
it works like a charm!

I amended it to bold the entire row:

(not sure how to make a code winod in this forum)

i = 1:
Do
If InStr(1, Cells(i, 1).Value, "Total", vbTextCompare) <
Then
Cells(i, 1).EntireRow.Font.Bold = True
End If
i = i + 1
Loop Until Cells(i, 1).Value = ""



out of interest, can you explain the parameters in the InStr function.
I understand what the Cells(i,1).Value does, but the vbTextCompare i'v
never come across, and the first '1' in the InStr...

thanks very much,

Mat

--
matp
-----------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=51310

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cycle through each row and look for string in each cell


Hello again, glad to hear it works fine - I only found out how to do it
myself yesterday when i was building a search tool using the InStr
function.

http://www.techonthenet.com/excel/formulas/

This is a good site to have a look at, it explaing how alot of
functions work inc the InStr one.


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513103

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cycle through each row and look for string in each cell

The 1 tells it to start looking at the first character.
vbTextCompare tells it to make a text comparison, which is not case
sensitive.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"matpj" wrote in
message ...

hi,

thanks for the code!
it works like a charm!

I amended it to bold the entire row:

(not sure how to make a code winod in this forum)

i = 1:
Do
If InStr(1, Cells(i, 1).Value, "Total", vbTextCompare) < 0
Then
Cells(i, 1).EntireRow.Font.Bold = True
End If
i = i + 1
Loop Until Cells(i, 1).Value = ""



out of interest, can you explain the parameters in the InStr function.
I understand what the Cells(i,1).Value does, but the vbTextCompare i've
never come across, and the first '1' in the InStr...

thanks very much,

Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=513103





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cycle through each row and look for string in each cell

Hello,

The easiest / fastest solution i would suggest is to use conditional
formatting.
Select the first row of data in your sheet and use the conditional
format of...

[Formula is ] =NOT(ISERROR(FIND("total",A2)))

Where 'total' is the string you want to find and A2 is the cell to
check your string for.

Simply use the format painter to paint the conditional formats for the
rest of the rows in your sheet and viola!!!

note: when you paint the formats the cell reference will change to
compliment where you paint the conditional format.

You shouldn't need VB, unless am missing the point?

-davemac


matpj wrote:
Hi there,

I need to cycle through every row of data, look in column A and find if
the string "Total" exists in the cell.
the string will be part of another string. e.g. "D01234-A Total".

Every instance that is found of a cell in column A containing Total,
eill require the entire row to be made 'Bold' font.

does this sound do-able??


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=513103


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
How do I make a graph with 2-cycle X 3-cycle log-log graph paper? Charles A. Wilson Charts and Charting in Excel 1 December 17th 09 03:03 AM
How do I keep result from 1 iteration cycle to use in next cycle? sgl8akm Excel Discussion (Misc queries) 0 July 27th 06 08:28 PM
Change/cycle cell entry to next option from validation list (macro Neil Goldwasser Excel Programming 0 January 25th 06 07:58 PM
How do I: Cycle through selections by clicking on cell jasonsweeney[_10_] Excel Programming 3 January 22nd 04 12:22 AM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


All times are GMT +1. The time now is 08:38 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"