Solved

delete all formatting after last cell character

Posted on 2013-06-12
7
295 Views
Last Modified: 2013-06-14
I have a spreadsheet with 1000 email addressed imported into it. However, they do not have the underlining  nor do they operate as an email. I discovered that there is extraneous formattingin the cells that prevents me from using the emails.
I would like to have some vba code that steps through each cell in the usedrange and delete all formatting  after the comma  ending the emal address

Is it possible using delete or truncate to get rid of the extraneous formatting on the right side of the cell? If so , please let me know how
0
Comment
Question by:llawrenceg
  • 4
  • 3
7 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

pls try
Sub Doit()

For Each cell In ActiveSheet.UsedRange
    If InStr(1, cell.Text, ",") Then
        cell.Value = Left(cell.Text, InStr(1, cell.Text, ","))
    End If
Next ' cell
End Sub

Open in new window

Regards
0
 

Author Comment

by:llawrenceg
Comment Utility
Did not work. I've attached a mini dummy file to help. The original file has several rows of addresses but they are not "live" addresses. I have to delete the character space right after the comma and hit enter for the address to convert to a mailto: address.
I'm sending an email to hundreds and the email system  requires working email addresses each separated by a comma.
So if you can show me how to code for the delete after the comma and clicking enter, I would appreciate it
email-converter.xls
0
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

If I understand you well

 Hake, John@yahoo.com, sould become  Hake,John@yahoo.com,
Sub DoitOncemore()

For Each cell In ActiveSheet.UsedRange
        cell.Value = Replace(cell.Text, " ", "")
Next ' cell
End Sub

Open in new window


Regards
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:llawrenceg
Comment Utility
Not quite .
So if you can show me how to code for  deleting everthing after the last comma and clicking enter, I would appreciate it
I made an error on samle file
the addresses look like this
Preston.Rosemarie@yahoo.com, Hake.John@yahoo.com, Senna.Sharon@yahoo.com,
With a period in the name and a comma between addresses.

So I need to delete everything after the last comma and then hit enter for each cell
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

I think I am nearer to the solution

Sub Doit()

For Each cell In ActiveSheet.UsedRange
    If InStr(1, cell.Text, ",") Then
        cell.Formula = Replace(cell.Text, ",", "")
    End If
    cell.Formula = Trim(cell.Text)
    a = cell.Text
    ActiveSheet.Hyperlinks.Add cell, "mailto:" & cell.Text
Next ' cell

End Sub

Open in new window

Regards
0
 

Author Comment

by:llawrenceg
Comment Utility
Rgonzo1971:
I think we have it to the point I can finish it. Great learning experience for me.
Thank you
0
 

Author Closing Comment

by:llawrenceg
Comment Utility
Great work  Thanks for the lesson as well
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now