• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reply to: VBA advice

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "VBA advice"

Collapse

  • Pondlife
    replied
    Originally posted by northernladuk View Post
    Busted. I don't even know what VBA stands for let alone fix it
    Are you sure you're cut out to post in Technical?

    Leave a comment:


  • LisaContractorUmbrella
    replied
    Originally posted by pjclarke View Post
    Have you been reading my diary? That sounds suspiciously like my plans for later this evening ...

    Leave a comment:


  • pjclarke
    replied
    if I get stuck and need a professional on the job
    Have you been reading my diary? That sounds suspiciously like my plans for later this evening ...

    Leave a comment:


  • LisaContractorUmbrella
    replied
    Originally posted by pjclarke View Post
    Excel dates are being stored as a number. With the integer particle is holding the date and the time is being as a decimal, so you must comparing the integer part of date cellular with the integer part of current date/timing. Isn't It?

    Assuming your dates are coming in column 5 (or 'E') and mail addresses column 2 ('B') and the address data most correctfully is in rows 4 to 20, in a worksheet being named 'Data', something like:


    Sub SendSomeMail()

    Const DATECOL = 5
    Const MAILCOL = 2
    Dim Row As Integer
    Dim EmailAddress As String
    Dim DataSheet As Worksheet

    Set DataSheet = Worksheets("Data")
    For Row = 4 To 20
    If Int(DataSheet.Cells(Row, DATECOL).Value) = Int(Now()) Then
    EmailAddress = DataSheet.Cells(Row, MAILCOL).Value
    '' Mail Function here
    End If
    Next 'Row

    End Sub

    Needful done. Payment to Shawaddidi Consulting, Jersey.

    Many thankings.
    This may work with a bit of fiddling - thanks for that - I'll PM you if I get stuck and need a professional on the job

    Leave a comment:


  • LisaContractorUmbrella
    replied
    Originally posted by northernladuk View Post
    Busted. I don't even know what VBA stands for let alone fix it
    Awww bless ya

    Leave a comment:


  • DirtyDog
    replied
    Originally posted by LisaContractorUmbrella View Post
    Email address is contained within the spreadsheet - list will be updated regularly - each batch of emails will be around 20-30
    Where is the body of the email - is it also in Excel?

    If the email contents changes, then I would use Excel to generate a list of the email addresses to send to, separated by a comma, and then copy that into your email program as the CC/BCC list.

    eg.
    Col A = email addresses
    Col B = date
    Col C = =if(B=TODAY(),A,"")

    Then have a function to concatenate all the values in C into one field, and copy that list of email addresses into Outlook (or whatever)

    Leave a comment:


  • northernladuk
    replied
    Originally posted by LisaContractorUmbrella View Post
    Yep certainly can and payment when my problem is fixed So can you fix the problem and how much are you going to rush me NLUK??
    Busted. I don't even know what VBA stands for let alone fix it

    Leave a comment:


  • pjclarke
    replied
    In which case, if the length of the list may vary, you'll need to add some code to work out the end value for 'Row'.

    PM me for a quote ;-)

    Leave a comment:


  • LisaContractorUmbrella
    replied
    Originally posted by DirtyDog View Post
    Where is the email content defined? Is it in Excel as well, or are you trying to read the records from Excel into something else to compose and send the email? How many names are you talking about doing?
    Email address is contained within the spreadsheet - list will be updated regularly - each batch of emails will be around 20-30

    Leave a comment:


  • pjclarke
    replied
    Excel dates are being stored as a number. With the integer particle is holding the date and the time is being as a decimal, so you must comparing the integer part of date cellular with the integer part of current date/timing. Isn't It?

    Assuming your dates are coming in column 5 (or 'E') and mail addresses column 2 ('B') and the address data most correctfully is in rows 4 to 20, in a worksheet being named 'Data', something like:


    Sub SendSomeMail()

    Const DATECOL = 5
    Const MAILCOL = 2
    Dim Row As Integer
    Dim EmailAddress As String
    Dim DataSheet As Worksheet

    Set DataSheet = Worksheets("Data")
    For Row = 4 To 20
    If Int(DataSheet.Cells(Row, DATECOL).Value) = Int(Now()) Then
    EmailAddress = DataSheet.Cells(Row, MAILCOL).Value
    '' Mail Function here
    End If
    Next 'Row

    End Sub

    Needful done. Payment to Shawaddidi Consulting, Jersey.

    Many thankings.
    Last edited by pjclarke; 24 October 2013, 10:47.

    Leave a comment:


  • DirtyDog
    replied
    Where is the email content defined? Is it in Excel as well, or are you trying to read the records from Excel into something else to compose and send the email? How many names are you talking about doing?

    Leave a comment:


  • LisaContractorUmbrella
    replied
    Originally posted by northernladuk View Post
    Could you supply an address to send our invoices to and what are your payment terms?
    Yep certainly can and payment when my problem is fixed So can you fix the problem and how much are you going to rush me NLUK??

    Leave a comment:


  • northernladuk
    replied
    Could you supply an address to send our invoices to and what are your payment terms?

    Leave a comment:


  • LisaContractorUmbrella
    started a topic VBA advice

    VBA advice

    Morning chaps.

    I am trying to automatically send out emails based on a list contained in Excel - I have written the code which will send the email but what I can't work out how to do is send it only when certain conditions are met i.e. when the date shown in the spreadsheet is today's date.

    Spreadsheet format is basic with 5 columns but variable rows - name, email address, text column and then 2 date columns - I need code to send automated email to email address where the date in the corresponding row of the date column is today.

    Hope that makes sense - any advice much appreciated

Working...
X