Custom Function to find value and offset

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys,
I am in need for help.(
I would like to write a custom function which findes certain values and offset once it is found two columns to the right.

Code:
function Test(strText as string) as string
Select Case True
Case strText = "Good"
?? offset found cell one column to the right get and modify that cell
Case strText="Bad"
?? offset found cell one column to the right get and modify that cell
Case strText ="Worst"
?? offset found cell one column to the right get and modify that cell
Case else

End select
end function

That is what I like to have but I am not able to get it to work...

Many thanks for your helb

Greetings

Albert
 
If you only want to update 1 column why does the array hold data for 10 columns?
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Notrie,

The Column("J") is "Umsatztext" and in Column "Buchungstext" is the "SEPA-Lastschrift" ... but of course in "Buchungstext" there are others as well such as "SEPA-Gutschrift" eg... but as I need different calculations depanding on
what it is I need the function to perform only if "SEPA-Lastschrift" is found then use that function.. If you are finished with the function put it back into the cell where it was found and updated..

It needs to be like that .. not in a new worksheet.
 
Upvote 0
It could als just hold two as "Buchungstext" and "Umsatztext"
Buchungstext to find what I am looking for and Umsatztext to change
 
Upvote 0
Albert

I didn't add anything for a new workbook, it's in the original code, here:
Code:
Worksheets.Add
    
Range(ActiveCell, ActiveCell.Offset(UBound(Guthaben, 2) - 1, 9)).Value = Application.Transpose(Guthaben)
 
Upvote 0
Norie,

sorry yes that is a different thing it was the code where I started out trying to work it out.
But I dont need a new worksheet or workbook I need the data in the same workbook worksheet .. in column ("J") updated after it runs through the custom function.

Please can you tell me how??
 
Upvote 0
IBANAuszugsnummerBuchungsdatumValutadatumUmsatzzeitZahlungsreferenzWaehrungBetragBuchungstextUmsatztext
XXXX104.01.201604.01.20162015-12-31-20.57.38.150143EUR0SEPA-GutschriftAnna Maria Reitstätter Bichlachweg 4 6385 Schwendt
XXXX104.01.201604.01.20162016-01-04-12.40.46.80754EUR0SEPA-LastschriftVB Leasing Finanzierung Quellenstrasse 51 - 55 Wien
XXXX104.01.201604.01.20162016-01-04-12.40.46.734133EUR0SEPA-LastschriftAllianz Elementar Versicherungs-Aktiengesellschaft Hietzinger Kai 101-105 1130 Wien
XXXX104.01.201604.01.20162016-01-04-12.40.46.668468EUR0SEPA-LastschriftWüstenrot Versicherungs-AG
XXXX115.01.201615.01.20162016-01-15-07.53.04.182978EUR-4,9SEPA-LastschriftUPC BUSINESS AUSTRIA GMBH TF 222 EUR WOLFGANGGASSE 58-60 1120

<colgroup><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

The above is what I got

the below is what I want...

IBANAuszugsnummerBuchungsdatumValutadatumUmsatzzeitZahlungsreferenzWaehrungBetragBuchungstextUmsatztext
XXXX104.01.201604.01.20162015-12-31-20.57.38.150143EUR0SEPA-GutschriftAnna Maria Reitstätter Bichlachweg 4 6385 Schwendt
XXXX104.01.201604.01.20162016-01-04-12.40.46.80754EUR0SEPA-LastschriftVB Leasing Finanzierung
XXXX104.01.201604.01.20162016-01-04-12.40.46.734133EUR0SEPA-LastschriftAllianz Elementar Versicherungs-Aktiengesellschaft
XXXX104.01.201604.01.20162016-01-04-12.40.46.668468EUR0SEPA-LastschriftWüstenrot Versicherungs-AG
XXXX115.01.201615.01.20162016-01-15-07.53.04.182978EUR-4,9SEPA-LastschriftUPC BUSINESS AUSTRIA GMBH

<tbody>
</tbody>

in the same worksheet-- no transpose or add new worksheet all withouth just back into the same location as it was.

I am sure it is possible )
 
Last edited:
Upvote 0
Albert

Couldn't you just use the function as a UDF on the sheet?

For example you could put this in a spare column and copy it down.

=IF(I2="SEPA-Lastschrift", LastschriftenTextUpdate(J2) ,J2)
 
Upvote 0
Norie,
It is part of a bigger VBA project and I really would like it as I attent do to it ..
There is a way that it can be done I am sure of if.. I had it already so far that it got it next to the cell I wanted it.. but that is not good I really would need to column be updatet afer I run the Prozedur .(
 
Upvote 0
Albert

I understand that and my suggestion of using a formula is only something to make sure the function actually works.
 
Upvote 0
Norie,
the function works .-) I did already managed that I get the result in the next column but not in the same cloumn .( sad... and I tried so many different things and cant not get to how I am able to get it to work..
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top