Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default How to update a range of cells if cell value is equal to...

I am having trouble with a piece of code in excel 2007 where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to update a range of cells if cell value is equal to...

Hi Jen

Try the below and feedback

Dim rowCounter As Double
Dim bottomRow As Double

For rowCounter = 2 To bottomRow
If UCase(Sheets("Sheet3").Range("W" & rowCounter)) = "Y" Then
Sheets("Sheet3").Range("X" & rowCounter & ":BV" & rowCounter) = "N"
End If
Next


If this post helps click Yes
---------------
Jacob Skaria


"Jen_T" wrote:

I am having trouble with a piece of code in excel 2007 where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to update a range of cells if cell value is equal to...

Jen,

I am having trouble with a piece of code in excel 2007


What trouble? I ran this code and if it finds a Y in col 23 then the row as
far as column BV gets's populated with N. What happens for you?

Mike

"Jen_T" wrote:

where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to update a range of cells if cell value is equal to...


I should have added I prefer this line to yours

Sheet7.Range(("X" & rowCounter & ":BV" & rowCounter)).Value = "N"

Mike

"Mike H" wrote:

Jen,

I am having trouble with a piece of code in excel 2007


What trouble? I ran this code and if it finds a Y in col 23 then the row as
far as column BV gets's populated with N. What happens for you?

Mike

"Jen_T" wrote:

where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default How to update a range of cells if cell value is equal to...

My macro will not replace the values of all rows from columns"x" to "bv" if
"w" ="y", I need to have the macro does this from row 2 to last row.

"Mike H" wrote:


I should have added I prefer this line to yours

Sheet7.Range(("X" & rowCounter & ":BV" & rowCounter)).Value = "N"

Mike

"Mike H" wrote:

Jen,

I am having trouble with a piece of code in excel 2007


What trouble? I ran this code and if it finds a Y in col 23 then the row as
far as column BV gets's populated with N. What happens for you?

Mike

"Jen_T" wrote:

where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to update a range of cells if cell value is equal to...

Jacob has shown you the solution to that use

UCASE

If ucase(Sheet7.Cells(rowCounter, 23).Value) = "Y"

Mike


"Jen_T" wrote:

My macro will not replace the values of all rows from columns"x" to "bv" if
"w" ="y", I need to have the macro does this from row 2 to last row.

"Mike H" wrote:


I should have added I prefer this line to yours

Sheet7.Range(("X" & rowCounter & ":BV" & rowCounter)).Value = "N"

Mike

"Mike H" wrote:

Jen,

I am having trouble with a piece of code in excel 2007

What trouble? I ran this code and if it finds a Y in col 23 then the row as
far as column BV gets's populated with N. What happens for you?

Mike

"Jen_T" wrote:

where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default How to update a range of cells if cell value is equal to...

Hi Jacob,
The code is not working, it will not update rows 2 to last for columns X
through BV if W ="Y". Not sure what is wrong... I copied your code into a
module.


"Jacob Skaria" wrote:

Hi Jen

Try the below and feedback

Dim rowCounter As Double
Dim bottomRow As Double

For rowCounter = 2 To bottomRow
If UCase(Sheets("Sheet3").Range("W" & rowCounter)) = "Y" Then
Sheets("Sheet3").Range("X" & rowCounter & ":BV" & rowCounter) = "N"
End If
Next


If this post helps click Yes
---------------
Jacob Skaria


"Jen_T" wrote:

I am having trouble with a piece of code in excel 2007 where I would like to
check a cell value in column "W" which is column 23, if equal to "Y" than
update from columns "X:BV" row 2 to last row the value to "N", if not do
nothing.

I have attached the code I am currently using:

Dim rowCounter As Double
Dim bottomRow As Double


For rowCounter = 2 To bottomRow
If Sheet7.Cells(rowCounter, 23).Value = "Y" Then
Sheet7.Range("X" + Trim(Str(rowCounter)) + ":BV" + _
Trim(Str(rowCounter))).Value = "N"
End If
Next rowCounter
Any suggestions would be greatly appreciated. Thank you

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 range of cells in a column equal to another cell jggsfl New Users to Excel 1 December 21st 07 01:15 AM
How do I make a range of cells equal to one cell jggsfl Excel Discussion (Misc queries) 2 December 20th 07 10:01 PM
want highlight when all cells in range are equal Jane Excel Worksheet Functions 4 November 16th 05 01:53 AM
Determine which cells from a specific range equal a certain sum Maxter21 Excel Worksheet Functions 1 July 20th 05 09:44 PM
How do I select a range if one cells contents is equal to another KHarrison Excel Discussion (Misc queries) 2 December 20th 04 09:35 PM


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