Using FIND Function In Macro To Replace Value In Adjacent Cell?

Aug 10, 2012

I am using a macro to find a value in a cell and if found, replace the value in the cell to the left. Thr macro works fine - unless the value I am searching for does not exist. The answer is ( Ithink) an IF statement, but I am having problems with the errors, when I try the IF.

The macro below blows up at the ActiveCell.Offset(0, -1) = "109073X line with an error "Run-time error "1004" - Application-defines or object-defined error.

I've tried a number of things I've seen from this board but have not found a way past the error.

If the value is found, the macro moves to the else statment and stops at the ActiveCell statement with the above error. If the value is not found, then the macro goto NotFound.

Sub Macro2()
'
'Range("A1").Select 'Start from the home cell
Dim ValueFound As Object
Set ValueFound = Cells.Find(What:="Cirrus Reversals/CREDITS")
If ValueFound Is Nothing ThenGoTo NotFoundElseActiveCell.Offset(0, -1) = "109073X"'ActiveCell.FormulaR1C1 = "109073X"End If
NotFound:
End Sub

View 3 Replies


ADVERTISEMENT

Find, Replace With And Then Replace Adjacent Cell

Mar 18, 2009

I am trying to create a macro where it finds a a certain word in a column for example C. What i want it to do is find anything that says FWD_EUR and then replace that cell (e.g C2) with CASH_EUR_FWD and after it has done that it replaces the adjacent cell (e.g. D2) with EUR_FWD. I then want this to do the same with FWD_USD to CASH_USD_FWD and adjacent cell to USD_FWD.

View 2 Replies View Related

Find And Replace By Adjacent Cell Formula

Feb 4, 2014

Is there a formula that can find a keyword within a cell then replace it with a formula that will add the adjacent cell value up.

A1=103 B1=104
A2=104 B2=105
A3=105 B3=Out-1p-(1)
A4=110 B4=111
A5=111 B5=112
A6=112 B6=113
A7=113 B7=114
A8=114 B8=Out-3p-(23)

I am looking for a formula that can automatically calc (B3) to 106 (based upon cell A3) if the cell has a value of (*out*).

View 1 Replies View Related

Find Values On One Tab And Replace Data From Adjacent Cell

Apr 3, 2014

I have one sheet in my workbook called 'mapping' which has a list of codes on it, the length of which will vary on a periodic basis.

I have another fairly large sheet on the workbook called 'data' (around 2000 rows) that will also vary in size. I want to do a search on the data tab for each code that is contained on column 4 of the mapping tab and if the code is found, enters the corresponding value from column 1 of the mapping tab to the cell 6 columns to the left of where the code was found on the data tab (cols H and B in this case).

The issue I have is the codes maybe contained more than once on the data tab so I need the find/replace command to search the whole of the data tab and perform the task each time.

View 2 Replies View Related

Excel 2010 :: Macro To Perform Find And Replace Function

Apr 8, 2014

I have two sheets. One is named sheet1 where all my data is and sheet2 where all my values are. I want to do a find a replace on column N (sheet1) using the data in sheet2. Column A on Sheet2 has all the values that are found in column N and column B on Sheet2 has what the data should change to.

So for example:

Sheet1 says the following on column N:
cat
dog
lion
bear

Sheet2 says:
Column A
A1: Cat
A2: Dog
A3: Bear

Column B
B1: 2
B2: 8
B3:15

I want the values on column N to be replaced with 2, 8, 15 and so forth. I use excel 2010.

View 1 Replies View Related

Find All Occurences Of 1 Value & Replace Adjacent Cells

Feb 15, 2008

On the worksheet, I need to find wherever the cell value begins '2 X 4 ...' in column L, and then replace the cell value in the same row, in column K, with '113010'. In my attempts, my code just changes the first occurrence, not all occurrences.

I want to use VBA to do this.

Here's my code so far:

Sub Update_Product_IDs()

Application. ScreenUpdating = False
Dim i As Integer, iCount As Integer
Dim numberOfPMDs As Integer
Dim PMD_Name As Integer
Dim worksheetName As String
Dim worksheets_in_file As Integer
worksheets_in_file = Worksheets.Count
worksheetName = Worksheets(2).Name
numberOfPMDs = worksheets_in_file - 1

View 5 Replies View Related

Find And Replace Function Using Cell References And Wildcards

Mar 29, 2012

Any way to use a find and replace function involving a cell reference. I have a spreadsheet with ton of junky text burying information that I want. Here is a simplified example

A B
Book 345353hg dgdgsdgfd fff Book belongs to Jim
Sneaker fdg4 Sneaker is worn by Jan
Gum dfg s d e te4345Gum tastes great
Cake jklsjflsjfjikCake smells delicious

The pattern is that the A1 text appears in the B2 text. What I want is

Find *A1
Replace with blank
Find *A2
Replace with blank
and etc.

So that in the end, I get this:

B2
belongs to Jim
is worn by Jan
tastes great
smells delicious

I've looked at the functions of find, replace, substitute, left, and right and I can't seem to find the right one to do what I need.

View 3 Replies View Related

Catching Errors When Using The Find / Replace Function / Replace All

Apr 20, 2006

Need assistance with the code for catching errors when using the find / replace function in excel? In particular, I am trying to write code to break to an error message when the value or string searched for isn't found in the find / replace. At the minute I have just copied the standard code using a macro and all this does is return a message box saying X entries replaced.

View 3 Replies View Related

Macro Will Not Run Find And Replace With The Contents Of A Cell

Apr 3, 2007

I want to have a macro that will look at a few cells say A1 & A2 and then use the contents of the cells say 1Q07 & 2Q07 respectively to do a find and replace find 1Q07 and replace it with 2Q07. I want it to use the contents of the cell and not just the text because the contents of the cell will change each time used. I tride to do it here but I dont have it yet. It doesnt seem to pass the value to the variable and the variable doesnt seem to do the find and replace.

Private Sub Update_Click()

Application. ScreenUpdating = False
Dim quarter As String
quarter = CStr(txtquarter.Text)
txtquarter.Text = CStr(quarter)

Sheets("Income Statement").Select
Dim oneq As Single
Dim twoq As Single
Dim threeq As Single
Dim fourq As Single
Dim fiveq As Single

oneq = ActiveSheet.Range("A2").Value
twoq = oneq - 1
threeq = twoq - 1
fourq = oneq - 4
fiveq = oneq - 5

View 9 Replies View Related

Replace The Offset With Find Function?

Nov 25, 2012

I just want to replace the offset with find function. I have attached the sample file with the code. Just need a little change.

View 5 Replies View Related

Find And Replace Function - Change Text To Pop Out?

Sep 9, 2013

Here is the situation:
- Large block of text in one cell (1000+ words).
- I use the Find & Replace function (from the top menu) to find a specific word that may appear several times within the cell.
- Excel "highlights" the cell... but not the word specifically so I have to read all the text to find that word throughout the cell.

View 5 Replies View Related

Find, Replace Function: Formula Is Too Long

Oct 8, 2007

I'm receiving this message when I attempt to use the Find, Replace function. Formula is too long". I have a column of cells containing text only. ( about 2-3 paragraphs worth) I'm trying to replace a name with another name, which works fine where the cell contains a single or few sentences, but fails to replace when the cell contains too much information.

View 8 Replies View Related

Log Function In A Macro: Take Log Of Each Number (on The Base 2) And Show The Result In The Adjacent Column

Jun 12, 2007

I have a lots of number arranged in a column. I want to take log of each number (on the base 2) and show the result in the adjacent column. I want this to be in a macro and the results to be displayed all at a time (I dont want to drag the cursor down to get log values for number corresponding to each row).

View 6 Replies View Related

Macro For Find & Replace

Feb 10, 2009

I have a workbook (materials forecasting) that automatically pulls from another workbook (production schedule).

The materials forecasting workbooks are named in regards to the current Monday (ie 02-02-09.xls, 02-09-09.xls, etc). The production schedules are named in accordance with the financial periods and weeks, ie PD1WK1.xls, PD1WK2.xls, PD1WK3.xls, PD1WK4.xls, PD2WK1.xls, etc

The materials forecasting sheet looks two weeks out.

EXAMPLE (pretend that today is the first day of PD1WK1)

Cell C1 will reference PD1WK1.xls
Cell C2 will reference PD1WK2.xls

Each week I copy the old materials forecasting sheet and rename it to the current week (ie I take 02-02-09.xls and rename it to 02-09-09.xls). I have a bunch of macros set up to move my deliveries up a week and what not. One macro I would like to set up, however, is that by putting a value in a cell the find and replace macro will work.

EXAMPLE
Cell A1 will reference PD1WK2.xls
Cell A2 will reference PD1WK3.xls
Cell C1 will reference PD1WK1.xls
Cell C2 will reference PD1WK2.xls

Then I would have the macro find all instances of whatever value is in cell C2 and replace it with whatever value is in cell A2. Then likewise fore C1 and A1 respectively. (If you think about what I am doing here... all I am doing is moving the schedule up one week so that I am forecasting using the right schedule).

I can manually do this but I would prefer a macro based on a simple user input for when people fill in for me.

View 11 Replies View Related

Find And Replace Macro?

Feb 21, 2012

I have a column of about 10,000 lines which contains a description Sheet 1 Column B. On another sheet (2) I have about 200 lines of abbrevations. In coulmn A2 is the full name, and column b is the Abbrevation. I would like to create a macro that would go down the list in A2 Sheet 2, go to Sheet 1 B find that word and replace it with Sheet 2 B2 abbrevation. Is there a way to do that?

Sheet 1
A B
680385 LEAD SET WITH GRABBER CONNECTION21379 ABSORBENT CARBON DIOXIDE SODASORB 3LB
Sheet 2
A B
WORDAbbreviationABDOMINALABDOMANGIOGRAPHICANGIO

View 4 Replies View Related

Macro For Find And Replace

Apr 2, 2009

There are 1000's of XML tag with values.. i want a macro which should replace all the tags(the value which is in between angel brackets should only be removed and angel bracekst also should be removed) with or without space and tag value should remain unchanged.

View 9 Replies View Related

Macro To Find And Replace

Dec 31, 2003

I had written a macro about two years ago that replaced longer company names with common abbreviations. I store it in Personal.xls, and it has been relatively fast (2-5 sec for most projects with < 2000 rows). However, I tried it on a file with 15,000 rows, and it choked Excel - i.e. it wouldn't run and had to be force quite (Excel XP on Windows 2000).

Here is a portion of the macro (I have about 40 companies that need to be abbreviated, names here have been simplified to protect the guilty ). I stepped through a couple of these lines to see what would happen, and each line took at least 1-2 min.

Sub ChgCompNames()
Application.ScreenUpdating = False
Cells.Replace What:="Company AAAA", Replacement:="AAAA", LookAt:=xlPart, SearchOrder:=xlByRows
Cells.Replace What:="Company BBBB", Replacement:="BBBB", LookAt:=xlPart, SearchOrder:=xlByRows
Cells.Replace What:="Company CCCC", Replacement:="CCCC", LookAt:=xlPart, SearchOrder:=xlByRows
Cells.Replace What:="Company DDDD", Replacement:="DDDD", LookAt:=xlPart, SearchOrder:=xlByRows
Application.ScreenUpdating = True
End Sub

View 9 Replies View Related

Function To Return Value Of Adjacent Cell

Sep 18, 2008

I am trying to write a function that will return the value in cell B based on its position adjacent to cell A (above). Cell A contains its own formula and may the values may change.

View 9 Replies View Related

Adjacent Cell After Find

Oct 21, 2008

I am trying to calculate an adjacent cell to place an interger value after a find result. The following example, lets say location=$L$5, I need to calculate Cells(13,5).Value =n. Its for a page number and the cell I need is always to the right of the found cell.

View 2 Replies View Related

Macro For Multiple Find - Replace

Nov 29, 2012

I have two worksheets in same workbook.

Sheet1 on columnA contains my data.

Sheet2 on columnA contains the entries I am going to find on Sheet1 colA
columnB contains the entries I am going to replace with

I am currently working with these code but seems I cant make it work:

[Code] .........

View 5 Replies View Related

Find And Replace Script / Macro

Jun 22, 2008

Find and replace script / macro?

I'm not sure what type of function is needed for what I'm describing below. I'm thinking it is a script or macro? I don't know anything about writing scripts or macros and I am quite new to excel.

I'm trying to learn chinese and am making chinese flashcards for myself.

The fact that some of the cells have chinese characters probably doesn't matter, but I just want to be thorough in my description....

View 13 Replies View Related

Macro Find&replace Only Exact Value

Sep 24, 2009

This macro finds and replaces multiple values found on another sheet. however, it does not only take the exact value, also others.
Example:

If i want to change "Example 1", "Example 2", ... "Example 10" into "One", "two", etc. Example 10 then changes into "One 0" because it changes the Example 1 (without the 0 in 10) into One. Is there any way to alter this (or do you have another macro to replace multiple values?

View 2 Replies View Related

Find Replace Macro Stops After Row 37

Oct 2, 2008

Here is the find / replace vba I am using.

Sub Replace()
Cells.Replace What:=Chr(19), Replacement:="-", LookAt:=xlPart
Cells.Replace What:=Chr(24), Replacement:="'", LookAt:=xlPart
Cells.Replace What:=Chr(145), Replacement:="'", LookAt:=xlPart
Cells.Replace What:=Chr(146), Replacement:="'", LookAt:=xlPart
Cells.Replace What:=Chr(160), Replacement:="", LookAt:=xlPart

End Sub

It makes the replacements up to line 37, then stops. If you then delete the first 37 rows and re-run the macro, it again performs replacements, but only on the next 37 rows.

I would like the macro to do the whole sheet...

View 9 Replies View Related

Harder Find/replace Macro

Oct 28, 2008

way to find/ replace some null values in a range of selected cells in a column. I would like to select a first and last cell, and replace the value -999.25 with the average of the cells that are above and below it. If there are more than one -999.25 cells, I would like to do the same thing with the average of the cells that above and below the first and last -999.25.

I would also like the same macro to replace any value that is over 200 with the average of the cells above and below it...

View 9 Replies View Related

VBA Macro To Find And Replace In Word

Jul 22, 2009

The error is a Run-Time 450 (Too many arguments or invalid property assignment), when I click debug it highlights With Selection.Find

Sub TestTemplates()
Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim appWD As Object
Set appWD = CreateObject("Word.Application")

Sheets("Sheet1").Activate
s1 = ActiveSheet.Range("Name")
s2 = ActiveSheet.Range("Add1")
s3 = ActiveSheet.Range("Add2")

appWD.Visible = True
appWD.Documents.Open Filename:="C:UsersRemy LabueDocumentsCareCore WorkTest Letter TemplatesTest Letter 1.DOCX"

Call DoFindReplace(FindText:="(1)", ReplaceText:=s1)...................

View 9 Replies View Related

Find & Replace Across Two Workbooks - Macro

Oct 24, 2006

I have two worksheets in two separate workbooks. One contains only two columns - a list of codes and the corresponding name of an institution. The other workbook contains a column with the codes. I want to replace the codes in the second workbook with the names from the first workbook.

I found this code on [url] here: Find & Replace macro

Sub DoIt()
Dim rRange As Range, rCell As Range

On Error Resume Next
With Workbooks("Personal.xls")
Set rRange = .Sheets(1).Range("A1", .Sheet1.Range("B65536").End(xlUp))
End With
For Each rCell In rRange.Columns(1).Cells
Selection.Replace What:=rCell, Replacement:=rCell(1, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
Next rCell
On Error Resume Next
End Sub

This is exactly what I need, but like the last person who asked about it, I can't get it to work. I've gone through Dave's instructions a number of times, and now I'm stumped.

View 5 Replies View Related

Creating A Function Or Macro To Replace Data Between Cells.

Jun 2, 2009

I am trying to create a function that will evaluate a cell, lets call it B10, and depending on this numeric entry input data in cell ranges B14,B22.

What I am trying to do is create a list of locations for a packing slip that when I enter the corresponding location number (i.e. 200) that it will populate the shipping address in B14,B22.

Is this possible?

View 6 Replies View Related

Find And Replace Cells In A Particular Column By Using Macro

Apr 11, 2014

I have a excel which contains 5 columns in which 5th column data cells has to be replaced with another set of data which have relationship with other 4 columns data.

View 3 Replies View Related

Macro To Find And Replace Accented Characters

Aug 11, 2014

I have list of email ids and some of which contains accented characters.I need to replace these accented characters with regular character.

Example:

rian.pieda@intt.com.cn
ario.sancez@acca.com

View 2 Replies View Related

Using The .find Method And Getting Adjacent Cell Data

May 15, 2009

Until now if I needed to find a cell's data (and its adjacent data) I've been using code in the format of (for the purpose of this example, you can assume all data in coulmn 1 is unique. Functioning as aprimary key using incremeting integers):

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved