Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to change value 2 cols over from search

I'm not to good a complex macros so If someone could help I'd much
appreciate it.I like to create a macro to change to value of a cell 2
cols left of a search string,same row.I have a sheet with 25 cols and
7500 rows,at various places the string oz is in a cell,I need to change
the value in the cell 2 cols left,how could I do this with a macro
?.The search string is usually but not always the same col,the value to
be changed is always second col left. Thanks
SteveC

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro to change value 2 cols over from search

One way:

Public Sub ReplaceLeftOfOz()
Const sFIND As String = "oz"
Const vREPLACE As Variant = "<Your Value Here"
Dim rFound As Range
Dim sFoundAddr As String

With ActiveSheet
Set rFound = .Cells.Find( _
What:=sFIND, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not rFound Is Nothing Then
sFoundAddr = rFound.Address
Do
rFound.Offset(0, -2).Value = vREPLACE
Set rFound = .Cells.FindNext(rFound)
Loop Until rFound.Address = sFoundAddr
End If
End With
End Sub


In article .com,
wrote:

I'm not to good a complex macros so If someone could help I'd much
appreciate it.I like to create a macro to change to value of a cell 2
cols left of a search string,same row.I have a sheet with 25 cols and
7500 rows,at various places the string oz is in a cell,I need to change
the value in the cell 2 cols left,how could I do this with a macro
?.The search string is usually but not always the same col,the value to
be changed is always second col left. Thanks
SteveC

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to change value 2 cols over from search

thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to change value 2 cols over from search

Look at the sample code for the FindNext method. this should get you
started. If you need further help, post back.

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I'm not to good a complex macros so If someone could help I'd much
appreciate it.I like to create a macro to change to value of a cell 2
cols left of a search string,same row.I have a sheet with 25 cols and
7500 rows,at various places the string oz is in a cell,I need to change
the value in the cell 2 cols left,how could I do this with a macro
?.The search string is usually but not always the same col,the value to
be changed is always second col left. Thanks
SteveC



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 222
Default Macro to change value 2 cols over from search

" wrote:

I'm not to good a complex macros so If someone could help I'd much
appreciate it.I like to create a macro to change to value of a cell 2
cols left of a search string,same row.I have a sheet with 25 cols and
7500 rows,at various places the string oz is in a cell,I need to change
the value in the cell 2 cols left,how could I do this with a macro
?.The search string is usually but not always the same col,the value to
be changed is always second col left. Thanks
SteveC

Assuming you've search with a macro, your next line could be:-

ActiveCell.Offset(0, -2).Value = whatever


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
2 Cols To 2 Cols VLookup Comparison CuriousMe Excel Discussion (Misc queries) 4 December 21st 06 07:54 PM
Macro for single to multiple cols. Help! dfkelly42 New Users to Excel 5 July 1st 05 09:07 PM
Cond Format:re color 2 cols, skip 2 cols Tat Excel Worksheet Functions 2 June 22nd 05 06:43 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM


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