ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Scripts / Macros in Word and Excel (https://www.excelbanter.com/excel-discussion-misc-queries/217207-scripts-macros-word-excel.html)

dleo

Scripts / Macros in Word and Excel
 
Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!

Gary''s Student

Scripts / Macros in Word and Excel
 
If there is one than one address in a cell, are the addresses separated by a
comma?
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


dleo

Scripts / Macros in Word and Excel
 

Yes, they are separated by a comma with no spaces.

"Gary''s Student" wrote:

If there is one than one address in a cell, are the addresses separated by a
comma?
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


Gary''s Student

Scripts / Macros in Word and Excel
 
If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


dleo

Scripts / Macros in Word and Excel
 
Works great! Thank you!

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


dleo

Scripts / Macros in Word and Excel
 

It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


Gary''s Student

Scripts / Macros in Word and Excel
 
If you need the macro only with the workbook, then save the workbook and the
macro will be saved with it.

If you need the macro as a general tool, put the macro in an otherwise empty
workbook and save the workbook as an addin (.xla). Then with one click you
can always include the macro whenever you bring up Excel.
--
Gary''s Student - gsnu200828


"dleo" wrote:


It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


dleo

Scripts / Macros in Word and Excel
 

I want to have this as a general tool. Let me make sure I am doing this
right. I go to Tools -- Macro -- Visual Basic Editor. Insert -- Module.
Paste in the code. File -- Close and Return to Excel. Then let's say if I
want to make the shortcut key Ctrl+e, I could just go to Tools -- Macro --
Macros and click on options and set it there.

I cannot figure out how to save as an addin. I use Save As, but there is no
option in there. Any advice?

Thanks.

"Gary''s Student" wrote:

If you need the macro only with the workbook, then save the workbook and the
macro will be saved with it.

If you need the macro as a general tool, put the macro in an otherwise empty
workbook and save the workbook as an addin (.xla). Then with one click you
can always include the macro whenever you bring up Excel.
--
Gary''s Student - gsnu200828


"dleo" wrote:


It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!


Gord Dibben

Scripts / Macros in Word and Excel
 
FileSave AsSave asType

Scroll way down to bottom of list to find Excel Add-in(*.xla).

Ot Excel 2007 Add-in(*.xlam)


Gord Dibben MS Excel MVP

On Wed, 21 Jan 2009 14:59:02 -0800, dleo
wrote:


I want to have this as a general tool. Let me make sure I am doing this
right. I go to Tools -- Macro -- Visual Basic Editor. Insert -- Module.
Paste in the code. File -- Close and Return to Excel. Then let's say if I
want to make the shortcut key Ctrl+e, I could just go to Tools -- Macro --
Macros and click on options and set it there.

I cannot figure out how to save as an addin. I use Save As, but there is no
option in there. Any advice?

Thanks.

"Gary''s Student" wrote:

If you need the macro only with the workbook, then save the workbook and the
macro will be saved with it.

If you need the macro as a general tool, put the macro in an otherwise empty
workbook and save the workbook as an addin (.xla). Then with one click you
can always include the macro whenever you bring up Excel.
--
Gary''s Student - gsnu200828


"dleo" wrote:


It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!



dleo

Scripts / Macros in Word and Excel
 

Alright, so it's saved as an add-in now. Now what? I don't understand how
saving that allows me to have access to that macro every time I open Excel.
Should I be saving it a certain name or in a certain location? I just named
it the same as the macro name in all caps and put it in the MS Office library.

"Gord Dibben" wrote:

FileSave AsSave asType

Scroll way down to bottom of list to find Excel Add-in(*.xla).

Ot Excel 2007 Add-in(*.xlam)


Gord Dibben MS Excel MVP

On Wed, 21 Jan 2009 14:59:02 -0800, dleo
wrote:


I want to have this as a general tool. Let me make sure I am doing this
right. I go to Tools -- Macro -- Visual Basic Editor. Insert -- Module.
Paste in the code. File -- Close and Return to Excel. Then let's say if I
want to make the shortcut key Ctrl+e, I could just go to Tools -- Macro --
Macros and click on options and set it there.

I cannot figure out how to save as an addin. I use Save As, but there is no
option in there. Any advice?

Thanks.

"Gary''s Student" wrote:

If you need the macro only with the workbook, then save the workbook and the
macro will be saved with it.

If you need the macro as a general tool, put the macro in an otherwise empty
workbook and save the workbook as an addin (.xla). Then with one click you
can always include the macro whenever you bring up Excel.
--
Gary''s Student - gsnu200828


"dleo" wrote:


It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!




Gord Dibben

Scripts / Macros in Word and Excel
 
Now you go to ToolsAdd-ins and enable the add-in by checkmarking it.

With the sheet of doubled-up email addresses active, just hit CTRL + e and
the macro will run and clean them up.

Note: macros in add-ins will not show up in the ToolsMacroMacros dialog
so must be run via shortcut or assigned to a button or typed into the above
dialog refedit box.

To avoid any potential conflict I would not give the add-in and the macro
the same name.

Easier at this point to change the macro name to something else.


Gord

On Wed, 21 Jan 2009 16:39:01 -0800, dleo
wrote:


Alright, so it's saved as an add-in now. Now what? I don't understand how
saving that allows me to have access to that macro every time I open Excel.
Should I be saving it a certain name or in a certain location? I just named
it the same as the macro name in all caps and put it in the MS Office library.

"Gord Dibben" wrote:

FileSave AsSave asType

Scroll way down to bottom of list to find Excel Add-in(*.xla).

Ot Excel 2007 Add-in(*.xlam)


Gord Dibben MS Excel MVP

On Wed, 21 Jan 2009 14:59:02 -0800, dleo
wrote:


I want to have this as a general tool. Let me make sure I am doing this
right. I go to Tools -- Macro -- Visual Basic Editor. Insert -- Module.
Paste in the code. File -- Close and Return to Excel. Then let's say if I
want to make the shortcut key Ctrl+e, I could just go to Tools -- Macro --
Macros and click on options and set it there.

I cannot figure out how to save as an addin. I use Save As, but there is no
option in there. Any advice?

Thanks.

"Gary''s Student" wrote:

If you need the macro only with the workbook, then save the workbook and the
macro will be saved with it.

If you need the macro as a general tool, put the macro in an otherwise empty
workbook and save the workbook as an addin (.xla). Then with one click you
can always include the macro whenever you bring up Excel.
--
Gary''s Student - gsnu200828


"dleo" wrote:


It's working fine and everything, but only for that document. If I exit
Excel and open it again, the macro is gone. How can I have it available every
time I open Excel?

"Gary''s Student" wrote:

If your data is in column A, then this:

Sub mailum()
n = Cells(Rows.Count, 1).End(xlUp).Row
k = 1
For i = 1 To n
v = Cells(i, 1).Value
If InStr(v, ",") 0 Then
s = Split(v, ",")
For j = LBound(s) To UBound(s)
Cells(k, 2).Value = s(j)
k = k + 1
Next
Else
Cells(k, 2).Value = v
k = k + 1
End If
Next
End Sub

will fill column B with single email addresses
--
Gary''s Student - gsnu200828


"dleo" wrote:

Every month I send out an e-newsletter to the people in my database. To get
the addresses I simply export their information into an Excel file,
copy/paste into Word, then copy/paste them into the e-mail.

In the exporting process however, multiple e-mails may be put into the same
Excel cell (ex. "). That means every
month I have to visually look down a long list to make sure each e-mail is on
its own line.

Is there some sort of macro or script I could create to eliminate this step?
Something along the lines of "If there is a "," move the rest of the cell
contents into a new cell below".

I am new to macros/scripts, so any help would be appreciated.

Thanks!





dleo

Scripts / Macros in Word and Excel
 

Alright, it's working now. Thank you so much for your help. I realized that
when saving the doc as an add-in, the bottom selection is called "Excel 2007
Add-in." That one didn't work, so I used the choice called "Microsoft Office
Excel Add-in." Took me a long time to realize that. :)

Thanks again!

"Gord Dibben" wrote:

Now you go to ToolsAdd-ins and enable the add-in by checkmarking it.

With the sheet of doubled-up email addresses active, just hit CTRL + e and
the macro will run and clean them up.

Note: macros in add-ins will not show up in the ToolsMacroMacros dialog
so must be run via shortcut or assigned to a button or typed into the above
dialog refedit box.

To avoid any potential conflict I would not give the add-in and the macro
the same name.

Easier at this point to change the macro name to something else.


Gord

On Wed, 21 Jan 2009 16:39:01 -0800, dleo
wrote:


Alright, so it's saved as an add-in now. Now what? I don't understand how
saving that allows me to have access to that macro every time I open Excel.
Should I be saving it a certain name or in a certain location? I just named
it the same as the macro name in all caps and put it in the MS Office library.



All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com