Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Finding a value and placing text on the cell to the right

I am searching down a column for a particular value and if found, I want to
check the cell to the immediate right to see if its empty. If it is, I want
to
insert a text value. If the cell to the right has a value already in it, I
want to move to the next available empty space to the right and put in
value. Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Finding a value and placing text on the cell to the right

Sub SearchingdownTheSelection()
for each cell in selection
if cell.Value = "particular" then
set cell1 = cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End Sub

replace selection with a specific range if you wish

for each cell in Range("B2:B200")

as an example.

--
Regards,
Tom Ogilvy

"Reggie" wrote in message
...
I am searching down a column for a particular value and if found, I want

to
check the cell to the immediate right to see if its empty. If it is, I

want
to
insert a text value. If the cell to the right has a value already in it, I
want to move to the next available empty space to the right and put in
value. Any help would be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Finding a value and placing text on the cell to the right

Thanks Tom for the quick response. I have another question. what if I wanted
to search another sheet to find a particular value? for example

On sheet1 I enter a value and I want to find that value on sheet2 and then
basically see if the cell to the right is empty if so put in a value. If its
not empty move another space to right and put in a value. Sorry I didn't
clarify this before.


"Tom Ogilvy" wrote:

Sub SearchingdownTheSelection()
for each cell in selection
if cell.Value = "particular" then
set cell1 = cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End Sub

replace selection with a specific range if you wish

for each cell in Range("B2:B200")

as an example.

--
Regards,
Tom Ogilvy

"Reggie" wrote in message
...
I am searching down a column for a particular value and if found, I want

to
check the cell to the immediate right to see if its empty. If it is, I

want
to
insert a text value. If the cell to the right has a value already in it, I
want to move to the next available empty space to the right and put in
value. Any help would be greatly appreciated.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Finding a value and placing text on the cell to the right

Sub Searching()
Dim cell as Range, v as Variant, cell1 as Range
v = lcase(Worksheets("Sheet1").Range("a1").Value)
with Worksheets("Sheet2")
for each cell in .Range("B2:B30")
if lcase(cell.Value) = v then
set cell1 = .cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End With
End Sub

--
Regards,
Tom Ogilvy



"Reggie" wrote in message
...
Thanks Tom for the quick response. I have another question. what if I

wanted
to search another sheet to find a particular value? for example

On sheet1 I enter a value and I want to find that value on sheet2 and then
basically see if the cell to the right is empty if so put in a value. If

its
not empty move another space to right and put in a value. Sorry I didn't
clarify this before.


"Tom Ogilvy" wrote:

Sub SearchingdownTheSelection()
for each cell in selection
if cell.Value = "particular" then
set cell1 = cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End Sub

replace selection with a specific range if you wish

for each cell in Range("B2:B200")

as an example.

--
Regards,
Tom Ogilvy

"Reggie" wrote in message
...
I am searching down a column for a particular value and if found, I

want
to
check the cell to the immediate right to see if its empty. If it is, I

want
to
insert a text value. If the cell to the right has a value already in

it, I
want to move to the next available empty space to the right and put

in
value. Any help would be greatly appreciated.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Finding a value and placing text on the cell to the right

Thanks Tom! it works perfectly

"Tom Ogilvy" wrote:

Sub Searching()
Dim cell as Range, v as Variant, cell1 as Range
v = lcase(Worksheets("Sheet1").Range("a1").Value)
with Worksheets("Sheet2")
for each cell in .Range("B2:B30")
if lcase(cell.Value) = v then
set cell1 = .cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End With
End Sub

--
Regards,
Tom Ogilvy



"Reggie" wrote in message
...
Thanks Tom for the quick response. I have another question. what if I

wanted
to search another sheet to find a particular value? for example

On sheet1 I enter a value and I want to find that value on sheet2 and then
basically see if the cell to the right is empty if so put in a value. If

its
not empty move another space to right and put in a value. Sorry I didn't
clarify this before.


"Tom Ogilvy" wrote:

Sub SearchingdownTheSelection()
for each cell in selection
if cell.Value = "particular" then
set cell1 = cells(cell.row,256).End(xltoLeft)(1,2)
cell1.Value = "text"
end if
Next
End Sub

replace selection with a specific range if you wish

for each cell in Range("B2:B200")

as an example.

--
Regards,
Tom Ogilvy

"Reggie" wrote in message
...
I am searching down a column for a particular value and if found, I

want
to
check the cell to the immediate right to see if its empty. If it is, I
want
to
insert a text value. If the cell to the right has a value already in

it, I
want to move to the next available empty space to the right and put

in
value. Any help would be greatly appreciated.






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
Placing Col & Row identifiers into a cell as text John Excel Worksheet Functions 3 May 28th 08 01:46 AM
Finding Text in a cell Klee Excel Worksheet Functions 3 February 20th 08 05:34 PM
Finding text in a cell and returning a value based on that text [email protected] Excel Discussion (Misc queries) 5 January 10th 07 06:01 PM
Finding text in a cell Art Excel Worksheet Functions 8 December 3rd 06 06:47 PM
Finding text within a cell Mike Excel Programming 4 April 5th 04 03:58 PM


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