ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search & Replace (https://www.excelbanter.com/excel-programming/299753-search-replace.html)

John Keturi

Search & Replace
 
Trying to get this to work. I want the macro to search a row for a certain
value, then search the column for a certain value, then return a certain
value into the corresponding cell. Thanks



Norman Jones

Search & Replace
 
Hi John,

Apparently pertinent to your request, Patrick Malloy recently posted the
following:
----------------------------------------------------------
Option Explicit
Sub Test()
FindAndReplace "Marty", "CA", _
Range("MyData"), "New Stuff"

End Sub

Private Sub FindAndReplace(sCol As String, _
sRow As String, _
rTable As Range, _
sNewValue As String)
Dim iCOL As Long
Dim iROW As Long

On Error Resume Next

iCOL = Application.WorksheetFunction.Match( _
sCol, rTable.Rows(1), False)
iROW = Application.WorksheetFunction.Match( _
sRow, rTable.Columns(1), False)

If iCOL * iROW = 0 Then
MsgBox "Not Found"
Else
rTable.Cells(iROW, iCOL) = sNewValue
End If
on error goto 0
End Sub

Patrick Molloy
Microsoft Excel MVP
-------------------------------------------------------

---
Regards,
Norman


"John Keturi" wrote in message
news:rAytc.325$mm1.24@fed1read06...
Trying to get this to work. I want the macro to search a row for a certain
value, then search the column for a certain value, then return a certain
value into the corresponding cell. Thanks





david mcritchie

Search & Replace
 
Hi John,
http://www.mvps.org/dmcritchie/excel/vlookup.htm#match
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"John Keturi" wrote in message news:rAytc.325$mm1.24@fed1read06...
Trying to get this to work. I want the macro to search a row for a certain
value, then search the column for a certain value, then return a certain
value into the corresponding cell. Thanks






All times are GMT +1. The time now is 08:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com