replacing and adding text HELP :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

replacing and adding text HELP
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

replacing and adding text HELP

Hi!
I have 3 rows of info which i need to create formula's for to do the following:
One column is of mobile numbers some of them are missing a "0" from the front of them. I need to have the old mobile number replaced with the new one with a "0" in front of it.
One column is of email addresses. I need to add a ".au" to 1 group of email addresses icon_help.gif with a specific domain.
Another column i have a value and i need it to have 200 removed from the value already existing in the cell if it is over 800 and be replaced with the result of the value-200

Post Mon May 26, 2003 11:32 am 
 View user's profile Send private message Send e-mail ICQ Number

gnaga
Board Master


Joined: 10 Jul 2002
Posts: 497

Flag: India

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

Microsoft Excel - Book1___Running: xl2002 XP : OS = Windows XP
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
E
1
     
2
1234560123456   
3
2523620252362   
4
15253601525361000800 
5
  800800 
6
  12001000 
7
     
Sheet1 

[HtmlMaker 2.32] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


What is that paritucular group of e-mail Id?
_________________
Regards
GNaga

Post Mon May 26, 2003 11:59 am 
 View user's profile Send private message

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

That is ok, but i need the result of the formula to be in the original text.
Therefore the info in B should overwrite the original data.
it needs to replace the original text.
Any idea?

Post Mon May 26, 2003 12:03 pm 
 View user's profile Send private message Send e-mail ICQ Number

gnaga
Board Master


Joined: 10 Jul 2002
Posts: 497

Flag: India

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

Can you give me the key to identify the group of e-mail? so that altogether I can try for VBA solution.
_________________
Regards
GNaga

Post Mon May 26, 2003 12:44 pm 
 View user's profile Send private message

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

I need to add ".au" to all Domains which have onnet.com
it also needs to replace the original email with the new one.
thanks so much for your time and assistance

Post Mon May 26, 2003 12:46 pm 
 View user's profile Send private message Send e-mail ICQ Number

gnaga
Board Master


Joined: 10 Jul 2002
Posts: 497

Flag: India

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

All the e-mail id ending with onnet.com should now be end with .au Am I correct?
_________________
Regards
GNaga

Post Mon May 26, 2003 12:50 pm 
 View user's profile Send private message

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

I can email u the file if its easier?
the email addresses have a username@onnet.com
needs to be replaced with username@onnet.com.au

Post Mon May 26, 2003 12:50 pm 
 View user's profile Send private message Send e-mail ICQ Number

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

yes thats correct

Post Mon May 26, 2003 12:54 pm 
 View user's profile Send private message Send e-mail ICQ Number

gnaga
Board Master


Joined: 10 Jul 2002
Posts: 497

Flag: India

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

Sub Test()
    Dim I As Long
    
    For I = 1 To Worksheets(1).Range("A1").End(xlDown).Row
        Worksheets(1).Range("A" & I).NumberFormat = "@"
        Worksheets(1).Range("A" & I) = "0" & Worksheets(1).Range("A" & I)
        
        If Worksheets(1).Range("B" & I) > 800 Then _
            Worksheets(1).Range("B" & I) = Worksheets(1).Range("B" & I) - 200
        
        If Trim(Mid(Worksheets(1).Range("C" & I), InStr(1, Worksheets(1).Range("C" & I), "@") + 1, _
                Len(Worksheets(1).Range("C" & I)) - InStr(1, Worksheets(1).Range("C" & I), "@"))) = "onnet.com" Then
            Worksheets(1).Range("C" & I) = Left(Worksheets(1).Range("C" & I), InStr(1, Worksheets(1).Range("C" & I), "@")) & ".au"
        End If
    Next I
End Sub


Try this code by keeping backup copy of your original file.
_________________
Regards
GNaga

Post Mon May 26, 2003 1:05 pm 
 View user's profile Send private message

gnaga
Board Master


Joined: 10 Jul 2002
Posts: 497

Flag: India

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

Try this one. Not the earlier one

Sub Test()
    Dim I As Long
    
    For I = 1 To Worksheets(1).Range("A1").End(xlDown).Row
        Worksheets(1).Range("A" & I).NumberFormat = "@"
        Worksheets(1).Range("A" & I) = "0" & Worksheets(1).Range("A" & I)
        
        If Worksheets(1).Range("B" & I) > 800 Then _
            Worksheets(1).Range("B" & I) = Worksheets(1).Range("B" & I) - 200
        
        If Trim(Mid(Worksheets(1).Range("C" & I), InStr(1, Worksheets(1).Range("C" & I), "@") + 1, _
                Len(Worksheets(1).Range("C" & I)) - InStr(1, Worksheets(1).Range("C" & I), "@"))) = "onnet.com" Then
            Worksheets(1).Range("C" & I) = Worksheets(1).Range("C" & I) & ".au"
        End If
    Next I
End Sub

_________________
Regards
GNaga

Post Mon May 26, 2003 1:10 pm 
 View user's profile Send private message

treacle
Board Regular


Joined: 26 May 2003
Posts: 13

Flag: Australia

Status: Offline

 Reply with quote  

Re: replacing and adding text HELP

thanks for ur help

Post Mon May 26, 2003 1:14 pm 
 View user's profile Send private message Send e-mail ICQ Number
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.