Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 8
Default help with loop code

please how can i say in this code... do it when you see "ok" in cells of column "P" and if any empty cells ignore it and continue?

this is the Code:

I = I + 1
Cells(1, "J").Value = "Outlook sent Time,Dynamic msg preview count =" & I - 3
Loop While Cells(I, "P").Value = "ok"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default help with loop code

Hi,

Am Wed, 15 Mar 2017 14:24:06 +0000 schrieb eltyar:

please how can i say in this code... do it when you see "ok" in cells of
column "P" and if any empty cells ignore it and continue?

this is the Code:

I = I + 1
Cells(1, "J").Value = "Outlook sent Time,Dynamic msg preview count ="
& I - 3
Loop While Cells(I, "P").Value = "ok"


try:

Sub Test()
Dim LRow As Long
Dim i As Long, j As Long
j = 1
With ActiveSheet
LRow = .UsedRange.Rows.Count
For i = 1 To LRow
If .Cells(i, "P") = "ok" Then
.Cells(i, "J") = _
"Outlook sent Time,Dynamic msg preview count =" & j - 3
j = j + 1
End If
Next
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016
  #3   Report Post  
Junior Member
 
Posts: 8
Default

Dear Claus
thanks i appreciate your replay

here is my all code (this code to send emails directly to my customers from excel) because when i added yours it's not working

Code:
Sub sendmail()
i = 4
Do


EmailTo = Cells(i, "J").Value
CCto = Cells(i, "K").Value
Subj = Cells(i, "L").Value
Filepath = Cells(i, "M").Value
msg = Cells(i, "N").Value


Application.DisplayAlerts = False

Dim OutApp As Object
Dim OutMail As Object
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

SigString = Environ("appdata") & _
"\Microsoft\Signatures\mrm.htm"

If Dir(SigString) < "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = EmailTo
.CC = CCto
.BCC = ""
.Subject = Subj
.HTMLBody = msg & "<br" & Signature
'.body = msg & vbNewLine & vbNewLine & Signature
.Attachments.Add Filepath
.Display '.Send 'or use .Display

End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing



Application.DisplayAlerts = True

i = i + 1
Cells(1, "J").Value = "Outlook sent Time,Dynamic msg preview count =" & i - 3
Loop While Cells(i, "P").Value = "ok"


End Sub


thanks again for ur kind help
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
code won't loop Joanne Excel Programming 7 February 28th 08 01:40 PM
Add Loop to code Alex Excel Programming 1 November 28th 06 04:51 PM
Help with better loop code Sliman Excel Programming 1 March 16th 06 08:10 PM
How to Loop some code Phil Osman Excel Discussion (Misc queries) 2 August 19th 05 11:14 AM
VBE code in a loop loloflores Excel Programming 0 April 30th 04 12:28 PM


All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"