Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default find match then change cell value

In column A I have cells filled with text and in column B I have cells filled
with numbers. I need to check if the number in cell C1 equals any of the
numbers in column B. If a match is found then I need to change the text in
column A to CBO.
e.g.
Column A Column B Column C
aep 5 7
apa 0
gci 59
xto 5000
xle 7
oih 253
ed 8

Since the cell C1 = 7 equals the 7 from column B, I need to change the data
in column A from xle to cbo. Is this possible?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default find match then change cell value

Hi,

Try this

Sub aileen()
lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set MyRange = Range("B1:B" & lastrow)
For Each c In MyRange
If c.Value = Range("C1").Value Then
c.Offset(, -1).Value = "cbo"
End If
Next
End Sub

"aileen" wrote:

In column A I have cells filled with text and in column B I have cells filled
with numbers. I need to check if the number in cell C1 equals any of the
numbers in column B. If a match is found then I need to change the text in
column A to CBO.
e.g.
Column A Column B Column C
aep 5 7
apa 0
gci 59
xto 5000
xle 7
oih 253
ed 8

Since the cell C1 = 7 equals the 7 from column B, I need to change the data
in column A from xle to cbo. Is this possible?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default find match then change cell value

Sub matchAndChange()
Const columnA As String = "A"
Const columnB As String = "B"
Const columnC As String = "C"
Dim iLastRowColumnB As Long
Dim iLooperB As Long
Dim iLastRowColumnC As Long
Dim iLooperC As Long

iLastRowColumnB = Range(columnB & Rows.Count).End(xlUp).Row
iLastRowColumnC = Range(columnC & Rows.Count).End(xlUp).Row

For iLooperC = 1 To iLastRowColumnC
For iLooperB = 1 To iLastRowColumnB
If Range(columnB & iLooperB).Value = Range(columnC &
iLooperC).Value Then
Range(columnA & iLooperB).Value = "CBO"
End If
Next
Next
End Sub

"aileen" wrote:

In column A I have cells filled with text and in column B I have cells filled
with numbers. I need to check if the number in cell C1 equals any of the
numbers in column B. If a match is found then I need to change the text in
column A to CBO.
e.g.
Column A Column B Column C
aep 5 7
apa 0
gci 59
xto 5000
xle 7
oih 253
ed 8

Since the cell C1 = 7 equals the 7 from column B, I need to change the data
in column A from xle to cbo. Is this possible?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default find match then change cell value

Works perfectly. Thanks so much.

"Mike H" wrote:

Hi,

Try this

Sub aileen()
lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set MyRange = Range("B1:B" & lastrow)
For Each c In MyRange
If c.Value = Range("C1").Value Then
c.Offset(, -1).Value = "cbo"
End If
Next
End Sub

"aileen" wrote:

In column A I have cells filled with text and in column B I have cells filled
with numbers. I need to check if the number in cell C1 equals any of the
numbers in column B. If a match is found then I need to change the text in
column A to CBO.
e.g.
Column A Column B Column C
aep 5 7
apa 0
gci 59
xto 5000
xle 7
oih 253
ed 8

Since the cell C1 = 7 equals the 7 from column B, I need to change the data
in column A from xle to cbo. Is this possible?

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
Change formating in other sheet cell based on match condition Brandon[_2_] Excel Programming 6 September 2nd 09 09:41 AM
Stumped: Find first match in list then reference dif cell in row.. MeatLightning Excel Discussion (Misc queries) 4 December 9th 08 12:06 AM
How can find match of one cell from a column of cells? mat Excel Discussion (Misc queries) 1 October 26th 06 04:59 PM
Find first nonblank cell row # in pivot table using MATCH Space Elf Excel Worksheet Functions 2 February 14th 06 09:50 PM
Using VB to change sheet name to match cell contents Gary Paxson Excel Programming 4 May 24th 04 08:38 PM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"