Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
Kitana pe Simpatie.ro
Femeie
25 ani
Bucuresti
cauta Barbat
25 - 48 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] Replace Multiple Characters with Others [VBA FUNCTION] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Source:


So I created 2 lists of months, in R1:R12 the list below which I named FIND:
January
February
March
April
May
June
July
August
September
October
November
December

In S1:S12 the list below which I named REPLACE:
01
02
03
04
05
06
07
08
09
10
11
12

In your PERSONAL.XLSB file, in a module put the following UDF (User Defined Function):

Function REPLACETEXTS(strInput As String, rngFind As Range, rngReplace As Range) As String

Dim strTemp As String
Dim strFind As String
Dim strReplace As String

Dim cellFind As Range

Dim lngColFind As Long
Dim lngRowFind As Long
Dim lngRowReplace As Long
Dim lngColReplace As Long

lngColFind = rngFind.Columns.count
lngRowFind = rngFind.Rows.count
lngColReplace = rngFind.Columns.count
lngRowReplace = rngFind.Rows.count

strTemp = strInput

If Not ((lngColFind = lngColReplace) And (lngRowFind = lngRowReplace)) Then
    REPLACETEXTS = CVErr(xlErrNA)
    Exit Function
End If

For Each cellFind In rngFind

    strFind = cellFind.Value
    strReplace = rngReplace(cellFind.Row - rngFind.Row + 1, cellFind.Column - rngFind.Column + 1).Value
    strTemp = Replace(strTemp, strFind, strReplace)

Next cellFind

REPLACETEXTS = strTemp

End Function


Here's an example of the syntax:
=PERSONAL.XLSB!REPLACETEXTS(L2;$R$1:$R$12;$S$1:$S$12)

If you just want the formula without "PERSONAL.XLSB!" you will need to make a module in your workbook and then save the workbook as macro enabled, or make an add-in which will load with Excel.

More on find and replace without VBA - with SUBSTITUTE, INDEX  =SUBSTITUTE(SUBSTITUTE(B5;INDEX(find;1);INDEX(replace;1));INDEX(find;2);INDEX(replace;2))


_______________________________________


pus acum 4 ani
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
To substitute 1 character, see:

_______________________________________


pus acum 4 ani
   
Pagini: 1  

Mergi la