+ Reply to Thread
Results 1 to 6 of 6

VBA search for value and insert space two characters to the right

  1. #1
    Registered User
    Join Date
    12-08-2010
    Location
    Hamburg
    MS-Off Ver
    Excel 2007
    Posts
    4

    VBA search for value and insert space two characters to the right

    VBA search for value and insert space two characters to the right

    First of all a friendly hallo to all Forum members.

    Ok I've got about 20000+ lines of data that look like this:

    NODE S1 S2 S3 SINT SEQV
    1 -0.90520E-02-1.3410 -2.1393 2.1302 1.8640
    2 0.77851E-02-0.92696 -1.9901 1.9979 1.7314
    3 -0.34783E-01-1.1249 -2.0717 2.0370 1.7655
    4 0.36477E-01-0.93091 -2.0064 2.0429 1.7700
    5 0.83489E-02-0.92708 -1.9901 1.9985 1.7319

    And I want to insert a space behind "E-XX" so it will look something like this:

    NODE S1 S2 S3 SINT SEQV
    1 -0.90520E-02 -1.3410 -2.1393 2.1302 1.8640
    2 0.77851E-02 -0.92696 -1.9901 1.9979 1.7314
    3 -0.34783E-01 -1.1249 -2.0717 2.0370 1.7655
    4 0.36477E-01 -0.93091 -2.0064 2.0429 1.7700
    5 0.83489E-02 -0.92708 -1.9901 1.9985 1.7319

    At the moment the VBA code looks somewhat like this:

    Please Login or Register  to view this content.
    But unfortunately it has two major drawbacks. It is inefficient and thus quite slow and I have to edit the code every time I apply it to a new set of data depending on the number of lines.
    So my ides for improvement are the following.

    Find "E-" and insert a " " (space) two characters to the right of "E-"

    and

    No=(value in a specified cell)

    Unfortunately my web based research hasn't been to successful and all problems I found that were similar to mine were solved with code that is way out of my novas league.

    Any suggestions or help?

    Thank you for your time!

    the TUGuys
    Last edited by TUGuys; 12-09-2010 at 01:44 PM. Reason: violation of Forum rules

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA search for value and insert space two characters to the right

    fast as lightning:

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    12-08-2010
    Location
    Hamburg
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA search for value and insert space two characters to the right

    Thank you snb for answering so quickly.
    Your solution looks very elegant and clever to me, just need to test it.

  4. #4
    Registered User
    Join Date
    12-08-2010
    Location
    Hamburg
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA search for value and insert space two characters to the right

    Lets say E-** goes from E-01 to E-99 could one do the following?

    Please Login or Register  to view this content.
    Thanks again!

    Greetings the TUGuys
    Last edited by TUGuys; 12-09-2010 at 01:42 PM.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA search for value and insert space two characters to the right

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    12-08-2010
    Location
    Hamburg
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA search for value and insert space two characters to the right

    Quote Originally Posted by royUK View Post
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Sorry for that one!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1