C
Codea
Hi
This is my first post in here and I have just recently started learnin
programming Excel macros. I've been trying to do a tool that sends emai
to the person that is selected from the worksheet with the information
which is located on the selected row. This I can done but when I a
trying to send email that contains information from more than one row
have to raise my hands up.
I can use arrays to set the selected range etc. (A1:A3) to the arra
and even in to a multidimensional array but how can I insert thi
variable into a email message body? If I break down th
multidimensional array (3x3) to three one dimensionals and then joi
them the formatting goes wrong.
Example:
Invoice Date GrossAmount
111 01.01. 100
222 02.02. 200
I create arrays Invoice(2), date(2), grossamount(2).
If I know set them to my emailbody with join the view will change t
this:
111
222
01.01.
02.02.
100
200
which is not what I wanted.
If I use multi dimensional arrays I have no idea how to print all th
"cells" in to the screen or message. Etc. Msgbox (multiArray) won'
work.
I could set up certain limits, how many cells user can choose, bu
that's not reasonable since user have to be able select as many a
she/he want's to. The number of columns is however always three.
Any ideas how can I do this?
This is my code so far (the email part is not included):
Sub Mailia()
Calculate
Dim laskut() As String
Dim summat() As String
Dim paivat() As String
Dim i As Integer
Dim rivit As Integer
Dim laskulista As Variant
r = Chr(13)
rivit = Selection.Rows.Count
ReDim laskut(rivit)
ReDim paivat(rivit)
ReDim summat(rivit)
If ActiveCell = "" Then
MsgBox ("Valitse laskut, joita karhutaan")
Exit Sub
End If
Set Laskualue = Selection
Laskualue.Cells(1).Select
For i = 1 To rivit
laskut(i) = ActiveCell
summat(i) = ActiveCell(, 2)
paivat(i) = ActiveCell(, 3)
ActiveCell.Offset(1, 0).Select
Next i
laskulista = laskut
a = Join(laskut, r)
b = Join(summat, r)
c = Join(paivat, r)
...
Best Regards
Tim
This is my first post in here and I have just recently started learnin
programming Excel macros. I've been trying to do a tool that sends emai
to the person that is selected from the worksheet with the information
which is located on the selected row. This I can done but when I a
trying to send email that contains information from more than one row
have to raise my hands up.
I can use arrays to set the selected range etc. (A1:A3) to the arra
and even in to a multidimensional array but how can I insert thi
variable into a email message body? If I break down th
multidimensional array (3x3) to three one dimensionals and then joi
them the formatting goes wrong.
Example:
Invoice Date GrossAmount
111 01.01. 100
222 02.02. 200
I create arrays Invoice(2), date(2), grossamount(2).
If I know set them to my emailbody with join the view will change t
this:
111
222
01.01.
02.02.
100
200
which is not what I wanted.
If I use multi dimensional arrays I have no idea how to print all th
"cells" in to the screen or message. Etc. Msgbox (multiArray) won'
work.
I could set up certain limits, how many cells user can choose, bu
that's not reasonable since user have to be able select as many a
she/he want's to. The number of columns is however always three.
Any ideas how can I do this?
This is my code so far (the email part is not included):
Sub Mailia()
Calculate
Dim laskut() As String
Dim summat() As String
Dim paivat() As String
Dim i As Integer
Dim rivit As Integer
Dim laskulista As Variant
r = Chr(13)
rivit = Selection.Rows.Count
ReDim laskut(rivit)
ReDim paivat(rivit)
ReDim summat(rivit)
If ActiveCell = "" Then
MsgBox ("Valitse laskut, joita karhutaan")
Exit Sub
End If
Set Laskualue = Selection
Laskualue.Cells(1).Select
For i = 1 To rivit
laskut(i) = ActiveCell
summat(i) = ActiveCell(, 2)
paivat(i) = ActiveCell(, 3)
ActiveCell.Offset(1, 0).Select
Next i
laskulista = laskut
a = Join(laskut, r)
b = Join(summat, r)
c = Join(paivat, r)
...
Best Regards
Tim