jeffcoleky
Active Member
- Joined
- May 24, 2011
- Messages
- 274
This macro currently copies a range of cell which I select and then exports it to a CSV for me. I love it but i need it to do a little more..
I need the macro to copy, and paste as it currently does, but THEN TRIM off the last word from each cell.
The data will always be an address, in the below format:
Example:
CURRENT RESULT OF MACRO
DESIRED RESULT USING MACRO
Can anyone suggest changes to I could make to the macro to make this work?
Code:
Application.DisplayAlerts = False
Set myrng = ActiveWindow.RangeSelection
Set newbook = Workbooks.Add
With newbook
.Title = "export"
.SaveAs Filename:="C:\export\Workbook", FileFormat:=xlCSV
End With
myrng.Copy
Windows("workbook.csv").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks("workbook.csv").Save
Workbooks("workbook.csv").Close
Application.DisplayAlerts = True
On Error Resume Next
MsgBox ("Selection Successfully Exported")
End Sub
I need the macro to copy, and paste as it currently does, but THEN TRIM off the last word from each cell.
The data will always be an address, in the below format:
Example:
CURRENT RESULT OF MACRO
Code:
3017 Jeffrey Drive
2429 Middlerose Cir
6400 Skyline Dr.
0144 Nocturne Dr
3748 Trinity Park Drive
4301 Sir Barton Road
9331 Southern Ave
9173 Novell Dr
18054 Mondamon Dr
4155 Twin Oak Ln
8032 Guy Dr
7263 S 6th St.
9452 Determine Ln.
5055 Bluegrass Ave
DESIRED RESULT USING MACRO
Code:
3017 Jeffrey
2429 Middlerose
6400 Skyline
0144 Nocturne
3748 Trinity Park
4301 Sir Barton
9331 Southern
9173 Novell
18054 Mondamon
4155 Twin Oak
8032 Guy
7263 S 6th
9452 Determine
5055 Bluegrass
Can anyone suggest changes to I could make to the macro to make this work?