簡體   English   中英

Excel VBA - 從代碼中讀取單元格值

[英]Excel VBA - read cell value from code

從excel發送電子郵件的任務。 以下是示例列。 如何從循環中獲取電子郵件值? 謝謝

在此輸入圖像描述

這是我的代碼:

Dim rng As Range
   Dim row As Range
   Dim cell As Range
   Dim mydate As Date
   Dim myDiff As Long

Set 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

我想你需要這個......

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM