Excel VBA - 从代码中读取单元格值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17584531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel VBA - read cell value from code
提问by user2286756
task to send email from excel. Below is the example column. How I can get the email value from the loop? Thanks
从 excel 发送电子邮件的任务。下面是示例列。如何从循环中获取电子邮件值?谢谢
Here is my code :
这是我的代码:
Dim rng As Range Dim row As Range Dim cell As Range Dim mydate As Date Dim myDiff As LongSet rng = Range("E5:E17") Set rng2 = Range("F5:F17") Dim cell2 As Range
Dim i As Integer i = 5
For Each row In rng.Rows For Each cell In row.Cells
MsgBox cell.Value mydate = cell.Value myDiff = DateDiff("d", Date, mydate) Set rng2 = Range("F" & i) For Each cell2 In rng2 MsgBox cell2.Value Next cell2
If myDiff > -8 And myDiff < 8 Then aEmail.Send End If
i = i + 1 Next cell Next row
回答by matzone
I think you need this ..
我想你需要这个..
Dim n as Integer
For n = 5 to 17
msgbox cells(n,3) '--> sched waste
msgbox cells(n,4) '--> type of treatm
msgbox format(cells(n,5),"dd/MM/yyyy") '--> Lic exp
msgbox cells(n,6) '--> email col
Next