VBA needed that utilizes replace function

Hi,
 I have this simple VBA that allows me to select my range and put a symbol in front of the data:
Sub AddtoFront()
Dim Rng As Range
For Each Rng In Selection
Rng.Value = "~" & Rng.Value
Next Rng
End Sub
However, I am looking to expand this in a bit of a different way utilizing VBA. I want select my range and use replace to change the middle 6 digits with a * or letter.  Example test data:
9999999999999999
1111111111111111
2222222222222222
and make it look like this via VBA:
999999******9999
111111******1111
222222******2222
My ultimate goal is to create an Excel add in that can easily used.
I didn't quite understand how to be able to select a range and work with a string to accomplish the goal.
Any help would be appreciated.
Scott

Re: "use replace to change the middle 6 digits"
The followiing uses the "Mid" statement  to replace the characters.
Don't confuse that with the VBA.Mid function  which operates differently.
The data area must be selected before running the code.
Sub ChangeTheMiddle()
  Dim rng As Range
  Dim rCell As Range
  Dim strText As String
  Const STR_FILLER As String = "******"
 'tell excel what to work on (cells)
  Set rng = Selection.Cells
  For Each rCell In rng
    strText = rCell.Text
    If VBA.Len(strText) >= 12 Then
      Mid(strText, 7, 6) = STR_FILLER
      rCell.Value = strText
    End If
  Next 'rCell
End Sub
Jim Cone
Portland, Oregon USA
free & commercial excel programs (n/a xl2013)
https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2
 

Similar Messages

  • Bulk Replacements using Replace function in oracle 8i

    Hi All,
    Iam using oracle 8i version and i need to use Replace function for bulf replacements i mean i need to replace around 250 rows. So please anyone suggest me how to proceed
    on this request as iam using oracle 8i version.
    Thanks!
    Srini

    Write one update statement.
    The where condition is the filter what rows need to be touched.
    The SET condition will do the data change. For example it could use the REPLACE function if that is what it is needed.
    One single update statement over 20 rows would mean the task is done in BULK. 20 single updates that each handle one row would mean it is row by row = slow by slow processing.

  • Need Help in Replacement of Function Modules

    Hello all,
    I am working on Upgrade project from ECC 5.0 to ECC 6.0. I am facing problems for Replacement of two Obsolete Function Modules. Please give me a solution. FM's  are as follows.
    1) SET_AUTHORITY : This FM is obsolete in ECC 6.0 and there is not alternative FM present in help.sap.com or any other web portal.
    2) WS_QUERY : Here as per my knowledge we use class CL_GUI_FRONTEND_SERVICES and methods FILE_EXIST or DIRECTORY_EXIST as per the parameters in old FM. For parameter 'FS' we use 'FILE_EXIST' and 'DS' we use 'DIRECTORY EXIST'.
    But in our program prev. FM has parameter 'OS' i.e. Operating System.
    But there is not method called 'OS EXIST' or similar. Please suggest suitable method.
    Thanking you all in anticipation.
    Best Regards,
    Harish

    Hi Harish,
                       I too could not find any replacement for SET_AUTHORITY
    Obsolete Modules can be used in newer versions, but it is not supported by SAP in case of any technical issues.If you still need a replacement, you can replace it by the source code in the FM SET_AUTHORITY itself and modify according to your needs.
    Below is the source code of FM SET_AUTHORITY, so you can modify it according to your requirement.
      DATA: l_actvt  TYPE tact-actvt,
            l_hier   TYPE STANDARD TABLE OF sethier WITH HEADER LINE.
      CASE action.
        WHEN 'A    '.
          l_actvt = activity-add.
        WHEN 'C    '.
          l_actvt = activity-modify.
        WHEN 'D    '.
          l_actvt = activity-display.
        WHEN 'E    '.
          l_actvt = activity-delete.
        WHEN 'UD   '.
          l_actvt = activity-display.
      ENDCASE.
      CALL FUNCTION 'G_SET_TREE_IMPORT'
           EXPORTING
                no_descriptions  = 'X'
                no_rw_info       = 'X'
                setid            = set
                tabname          = table
                root_header_only = 'X'
           TABLES
                set_hierarchy    = l_hier
           EXCEPTIONS
                OTHERS           = 0.
      READ TABLE l_hier INDEX 1.
      IF sy-subrc <> 0.
        CLEAR l_hier.
        l_hier-shortname = set.
      ENDIF.
      CALL FUNCTION 'G_SET_AUTHORITY_CHECK'
           EXPORTING
                actvt  = l_actvt
                authgr = l_hier-authgr
           EXCEPTIONS
                OTHERS = 1.
      IF sy-subrc <> 0.
        CASE action.
          WHEN 'A    '.
            MESSAGE e827 WITH l_hier-shortname RAISING no_authority.
          WHEN 'C    '.
            MESSAGE e828 WITH l_hier-shortname RAISING no_authority.
          WHEN 'D    '.
            MESSAGE e829 WITH l_hier-shortname RAISING no_authority.
          WHEN 'E    '.
            MESSAGE e830 WITH l_hier-shortname RAISING no_authority.
          WHEN 'UD   '.
            MESSAGE e831 WITH l_hier-shortname RAISING no_authority.
        ENDCASE.
      ENDIF.
    If you need help in replacing in the above source code, please post your code here so that I can help you in modifying accordingly.
    Regards,
    Vasuki

  • VBA code that calls the Send Active Work Sheet function

    Hi There,
    I would like to know if it is possible to have a button that calls some VBA code that does the same as the u201CSend Active Work Sheetu201D function from the BPC action pane. I am developing a custom workbook, but would like to have a button that calls the send active worksheet and returns the status window .  "MNU_ESUBMIT_REFSCHEDULE_SHEET_REFRESH" sends the active worksheet but does not return a status window.
    Kind Regards
    Daniel

    I am unaware of any other "undocumented" features that might perform the exact scenario you are needing.  Perhaps this is an enhancement request.
    If you only need to display a generic informational dialog that data has been sent and not include the specifics of the data that was sent (ie: number records sent, accepted, rejected...).  Perhaps you could use one of the MNU_eSUBMIT_SHEET options that doesn't provide the results feedback and then in an AFTER_SEND() function pop-up a msgbox informing the user that data has been sent?
    Or, investigate the use of MNU_eSUBMIT_VALIDATE prior to the MNU_eSUBMIT_SHEET.....I personally have never used that option.

  • I need a BAPI or function that can create a PO without the purchase req.

    I need a BAPI or function that can create a PO without the reference to a purchase requisition. We are creating "direct POs" (with no reference to PR) manually. And we have a large amount of documents to create. I can't figure out if BAPI_PO_CREATE and BAPI_PO_CREATE1 can help us by doing this, because I've understood this BAPIs creates POs only with the reference to a purchase requisition.
    Thanks in advance!!
    Sebastian

    Sorry I'm late guys, I couldn't replay your posts because I was busy.
    Charlie,
    ...just because we have the data already in the SAP system.
    My client doesn't want purchase requisitions to be created from the PM orders. Instead he asked us to create the purchase workflow by generating direct purchase orders from the PM orders, basically taking the information from the purchase agreement within the order's tasks. Maybe you don't understand a bit what I'm saying, but let me get this straight: we can't use LSMW because data doesn't come from a legacy.
    Ian,
    ...after all, and like you've said, we're gonna use BAPI_PO_CREATE1 for creating the POs. Today I finally realized that, purchase requisitions aren't mandatory for the bapi to perform the process. If something goes wrong, I'll let you know.
    Thanks anyway for your attention.
    Sebastian

  • I recently had my account expire, and need to utilize the trial to finish a project. Even though my account says 'free trial' the applications will not open. How do I get the APP to recognize that I'm in trial and not expired?

    I recently had my account expire, and need to utilize the trial to finish a project. Even though my account says 'free trial' the applications will not open. How do I get the APP to recognize that I'm in trial and not expired?

    I had a year long CC membership that expired at the beginning of the October.
    After realizing that, I attempted to start a free trial of photoshop to work on a project. My Adobe account states that i'm on a trial, but my (Mac) dashboard CC app won't allow me to start the program. I have reinstalled both Creative Cloud and Photoshop CC but still get this message.

  • TS3274 My IPad is dead. Nothing will show on the screen. Screen not cracked and no water or liquid has been spilled on it. Is there a battery that needs to be replaced?

    My IPad is dead. Nothing will show on the screen. Screen not cracked and no liquid spilled on it. Is there a battery that needs to be replaced?

    Battery not charging:
    1. Reset iPad; hold the Sleep/Wake and Home button down until you see the Apple Logo
    2. Try another wall socket
    3. Try another cable (make sure it's an original Apple cable)
    4. Try another charger (make sure it's an original Apple charger)
    5. Clean Lightning port with compress air or new paint brush

  • Hi I bought an iPhone 5 from a friend. but he got it as a warranty replacement from Apple so he has no paperwork with the serial/IMEI. I need that kind of paperwork to be able to use my phone at work. what do I do to get it?

    Hi I bought an iPhone 5 from a friend. but he got it as a warranty replacement from Apple so he has no paperwork with the serial/IMEI. I need that kind of paperwork to be able to use my phone at work. what do I do to get it?

    That information, and more, can be found in the About page of the settings. Tap Settings > General > About and you'll see a lot of information about the device.

  • HT4509 I want to make an app that utilizes the international keyboard function but so that users can more easily select numbers. Is this possible?

    Is it possible to utilize that international keyboard function so that a user can select numbers more easily. Just like using for emoticons but rather have an easier way to select numbers.

    Hi j.v.
    Have you tried the Linksys forums? I think you may get more help from a network type forum that uses the WAP54G than the Apple forums.
    regards

  • Help needed in building a function

    Hello,
    I am using Oracle DB 11g.
    I am writing a function.
    create or replace function func(tab VARCHAR2) RETURN VARCHAR2 AS
    cursor c is SELECT column_name
    FROM all_tab_columns
    WHERE table_name =tab;
    begin
    //some statements
    for i in c loop
    flag=1;
    //some statements
    end loop;
    //use the same c cursor query
    if flag!=1 then
    //repeat the block inside the for loop;
    end if;
    end;
    Function works fine.
    Now once the for loop ends,what i want is if it doesn't enter the for loop, then for just for once enter the if condition for
    any column from the table and repeat the process, which i am doing inside the for loop.
    But here i am finding repetition of same query and the block of code.
    Is there any way i can avoid that?
    Thanks

    How about you start from scratch and explain the business problem you are attempting to solve. Not a portion of a technical implementation that doesn't seem to make any sense.
    Start from the beginning, no code ... just "i have a situation where i need to .... ".
    Should be a lot more productive.

  • Replace() function doesn't work in Application Designer?

    I'm using PeopleSoft Application Designer 8.51. I'm trying to do a simple Replace function so I can escape single quotes rather than allow them to blow up the sql query.
    &deptid = Replace(&deptid, "'", "''");
    App Designer chokes when I hit Save: "Invalid function parameter type. (2,19)"
    According to the docs I'm using this correctly: http://docs.oracle.com/cd/E26239_01/pt851h3/eng/psbooks/tace/book.htm?File=tace/htm/tace14.htm#H4095
    Even if I try to execute the example right out of the documentation, I get the same error: REPLACE("StringFun", "Fun", "Number");
    Is this a bug in app designer? REPLACE is a super common thing, it's not something obscure. How can this not work?
    Thanks in advance.

    I figured this out. “Replace” is a strange duck function that relies on offsets. “Substitute” is the magic I needed, works just like I was expecting Replace to work. The documentation I was reading on Replace was for “ PeopleSoft Analytic Calculation Engine” rather than peoplecode. I’ll pay closer attention to that next time. Maybe this will help someone else...

  • Replace function in TT7

    Hi,
    I have a database in TT Release 7.0.3.1.0 and other in Release 11.2.2.4.0. I need use replace sql function over Release 7.0.3.1.0.
    I know that it not apply in this version but I've tried with ttIsqlCS in node with TT11 through connection in database TT7 but I received this error:
    ttIsqlCS database_test_R7
    Command> select replace('asjkhdfkhaskdh','a','1') from dual;
    2818: Unknown function REPLACE
    The command failed.
    Command> version;
    TimesTen Release 11.2.2.4.0
    Any idea ??
    Thanks in advance.
    Babs.

    Hi Babs,
    I am afraid that you are out of luck. SQL is implemented in the TimesTen engine/libraries not in the ttIsql client. Since 7.0 SQL does not have th REPLACE() function there is no way to execute that in 7.0 regardless of the client you use. You'll need to find some other option to accomplish what you require (maybe upgrade the 7.0 database to 11.2.2?).
    Chris

  • Replace function help

    Hi all, sry for post sql problens in APEX forum, but i realy need help for this...
    I´m trying to replace : for , to make a select where in () with more then one value... but the replace function its not work with more then 1 value...
    like this
    select name from vw_requerente where id_cliente in REPLACE(:P5000_CLIENTE,':',',')in that item has this value: 71:72:73 , but all i get is a ORA: INVALID NUMBER, how can i make a replace function to work with this?
    tnks alot and sry my english.

    He also posted this in the pl/sql forum and received some good advice there:
    replace function help
    Especially the tom kyte blog portion:
    [http://tkyte.blogspot.com/2006/06/varying-in-lists.html]
    Thank you,
    Tony Miller
    Webster, TX

  • Replace function and '-' character

    Hello,
    How can I use '-' character in a REPLACE function?
    create or replace procedure zd authid current_user as
    begin
    execute immediate ' create table select ZDK
    Replace(SO_HEADER.ZDNUMBER,'' - '','' '') from so_header';
    end zd;
    Thanks a lot,

    Hm. I don't see that you want to replace the minus "-". If you truely ment the underscore "_" then you are right. Sometimes it must be escaped since it has the special meaning of "any single character" (same as the ? wildcard for microsoft users). However this is only true for the LIKE operator. Not for the REPLACE function.
    examples (non dynamic)
    select SUBSTR(Replace('123\456\789\', '\'),7,7) from dual;
    789
    select SUBSTR(Replace('123_456_789_', '_'),7,7) from dual;
    789The escape keyword in not allowed anywhere inside the replace function.
    What was your intended input and output?
    Just a recommendation. You don't need to specify the third paramater if you just want to remove the search string.
    And your insert statement is not dynamic. If you don't create the table dynamically then you can simply write the insert statement inside pl/sql without the need to make it dynamic. This would make testing and debugging much easier!
    Edited by: Sven W. on Jul 27, 2011 7:56 PM

  • Search & Replace function in Files?

    Does there exist a "Search & Replace String" function for Files IO? ...preferable RandomAccessFile.
    Or do I have to make my own parser from scratch.
    Anyone know of free code that exists somewhere? This seems like a function that someone must have made at least or has a use for.
    Thanks for any! :)
    rasmasyean

    The JDeveloper Editor provides Search & Replace functionality for files.
    What I typically do is
    Select menu: Search | Search Source Path...
    Enter Search String and Change Source path
    and other fields and press Start
    Then the Navigator displays a Search tab which lists all files with the matching string.
    Double click on first file in navigator and
    select menu Search | Replace
    In this dialog enter your search, replace, and other options-
    In the Options, If you do not want to be prompted, do not check the Prompt on replace option.
    Select the Scope of Global
    Selectg the Origin of Entire
    When you are ready press the Multiple button to make multiple replacements.
    When you are done with this file,
    Press Ctrl-S to Save the file
    Press Ctrl-F4 to close the window
    Double click on the Next File
    Press Ctrl-R to invoke the Search | Replace dialog.
    You should not need to change any options.
    Press Alt-M to select the Multiple Button!
    While this may seem more complex then a simple Sed / Perl / Python script, it is more controllable, flexible and user friendly.
    Besides, you may learn a few JDeveloper tricks.
    Good Luck,
    -John

Maybe you are looking for

  • Incorrect drive space on 40 GB click wheel

    I have an out of warranty 40 Gb clickwheel (does that make it a 4th generation? - purchased 10/04) that froze on me last week. I had to do a reset/then a restore, but when I did that, the drive info now only shows the drive to have 16 gigs of capacit

  • Query on PO?

    Hi Friends Is it possible to create PO from group of shopping carts without sending it to sourcing cockpit. Thanks & Regards Kanni.

  • Copying, pasting and editing audio problem?

    hi, i have some audio tracks that i originally recorded in pro tools le (no plugin delay compensation if using uad's or other 3rd party plugs dont even go there by the way) and have exported them to logic 8 and changed the arrangment for a song. The

  • Playing .wav and .mpg3 files in Java fx app on macmini Lion (10.7.3)

    A coder I am working with has created an app written using Java fx. I am able to open the the app .jar on a macmini running Lion (10.7.3) using Java 7 and the javafx-sdk 2.2.0-beta, but the .wav and .mpg3 files that run on a on a pc playing the app d

  • Compile class file, check for code structure quality

    now i am trying to develop a system for my college final year project..the main function is to help the lecturer to mark the student java assignment any way to compile the java file..just to check for the error? if got error then 0 mark..no error got