Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cell Text Search & Insert Value in Next Column

Hello I have a small problem searching for a value then getting the
value in the next column. If "spontaneous" is in the cell then I'd
prefer the next column's (B) cell to be 1 instead of the word in column
A being replaced with 1 (e.g. c.Value="1").

Would it be something like c.[offset].Value="1"?

Thanks for your help!

Shaun

--Code--
With Worksheets(1).Range("a1:a5")
Set c = .Find("spontaneous", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = "1"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Cell Text Search & Insert Value in Next Column

c.offset(0,1).Value = "1"

But with 5 cells, I would think just looping through the cells would be easier.

Shaun wrote:

Hello I have a small problem searching for a value then getting the
value in the next column. If "spontaneous" is in the cell then I'd
prefer the next column's (B) cell to be 1 instead of the word in column
A being replaced with 1 (e.g. c.Value="1").

Would it be something like c.[offset].Value="1"?

Thanks for your help!

Shaun

--Code--
With Worksheets(1).Range("a1:a5")
Set c = .Find("spontaneous", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = "1"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cell Text Search & Insert Value in Next Column

Thanks for your help David, works perfectly!

Usually I work with cells(iRow, iColumn).value to target other cells so
this offset and range stuff was confusing :).

I was limiting it to only 5 cells because I was getting error 91 about
wrong object / while values. I thought it has something to do with the
value being replaced so this offset seems to have fixed that problem
also.

Shaun

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Cell Text Search & Insert Value in Next Column

Glad you got it working.



Shaun wrote:

Thanks for your help David, works perfectly!

Usually I work with cells(iRow, iColumn).value to target other cells so
this offset and range stuff was confusing :).

I was limiting it to only 5 cells because I was getting error 91 about
wrong object / while values. I thought it has something to do with the
value being replaced so this offset seems to have fixed that problem
also.

Shaun


--

Dave Peterson
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
Insert cell text every 5 rows in a column Mike Mike Excel Discussion (Misc queries) 9 September 16th 10 09:53 AM
Insert Column after specific text title the new column and add for David Excel Discussion (Misc queries) 5 October 2nd 09 04:03 PM
Q on how to search for text in a column TheMilkGuy Excel Discussion (Misc queries) 5 May 15th 09 04:48 PM
how to - Insert predifined text in each cell of a column npereira[_11_] Excel Programming 3 October 18th 05 09:52 PM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM


All times are GMT +1. The time now is 03:43 PM.

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"