+ Reply to Thread
Results 1 to 3 of 3

Can You Put An IF Statement Inside a REPLACE Statement?

  1. #1
    Forum Contributor
    Join Date
    04-06-2006
    Posts
    131

    Question Can You Put An IF Statement Inside a REPLACE Statement?

    Hey Everyone!!

    I'm not too sure how to accomplish this, or if this is even possible... Basically, I have a line that is doing a basic Find and Replace:
    Please Login or Register  to view this content.
    Now, this works great - except that it works over and over... LOL So, every time it is run I get another line in between in the TextBox where Template2 is being displayed.

    For example, the first time is is run <BR> becomes <BR>vbCrLf. This is great. But then the next time it runs, it becomes <BR>vbCrLfvbCrLf, then <BR>vbCrLfvbCrLfvbCrLf, and so on and so forth from there.

    Is there a way I could add an IF function in there, so that it would search the Template variable and look at each <BR> individually, then only do the Replace if the vbCrLf part is not already there?

    Thank you for your help. I really appreciate it!!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Can You Put An IF Statement Inside a REPLACE Statement?

    try:
    Please Login or Register  to view this content.
    if there are two consecutive vbcrlf's they will be replaced by one
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    04-06-2006
    Posts
    131

    Re: Can You Put An IF Statement Inside a REPLACE Statement?

    Dood!! Brilliance in it's simplicity!! It worked like a charm - thanx a million!! :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. If statement inside and if statement...possible in VBA?
    By strud in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 07:42 AM
  2. Using a VLOOKUP and IF statement inside an IF statement
    By Isis3 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-08-2011, 07:04 PM
  3. Using Next inside an IF statement
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2010, 10:27 AM
  4. if-statement inside an if-statement
    By ebswd in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2009, 12:39 AM
  5. If, then inside a for, next statement?
    By EnergyEngineer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-10-2007, 05:04 PM

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