+ Reply to Thread
Results 1 to 4 of 4

quick vba question - how do you refer to a cell

  1. #1
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Question quick vba question - how do you refer to a cell

    I have a code that I can attach to a button in excel so that when clicked - it automatically sends an email of my choosing to whom I declare it to... HOWEVER.. that is fine when attached the macro to a button.

    BUT, what I now need to do is to apply this code (or similar) to a change in a specific cell?

    my problem is i cant for the life of me figure out how to do that in vba. i just don't know the commands to do that.

    all i need is an example of someone using an If/else statement referring to a specific cell on the spreadsheet - (e.g. if c4 = something, send the email)


    thanks.


    and i can do the rest

  2. #2
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: quick vba question - how do you refer to a cell

    to make it easier.. this is the code i have for the automatic email macro for a button

    Sub emailnotification()

    Dim OutApp As Object
    Dim OutMail As Object
    On Error Resume Next
    Err.Clear
    Set OutApp = GetObject(Class:="Outlook.Application")
    If Err <> 0 Then Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Training Expiry Date Warning"
    .Body = "This employee's current training is due to expire in 30 days - needs renewing"
    .Send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: quick vba question - how do you refer to a cell

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: quick vba question - how do you refer to a cell

    Thanks for reply John,

    This is the code I'm trying, but i know its wrong but i don't know how to edit it accordingly.


    Sub Expirydate()

    If Range("ah21").Value = "YES" Then

    Dim outapp As Object
    Dim outmail As Object
    On Error Resume Next
    Err.Clear
    Set outapp = GetObject(Class:="Outlook.Application")
    If Err <> 0 Then Set outapp = CreateObject("Outlook.Application")
    outapp.Session.Logon
    Set outmail = outapp.CreateItem(0)

    On Error Resume Next
    With outmail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Training Expiry Date Warning"
    .Body = "This employee's current training is due to expire in 30 days - needs renewing"
    .Send
    End With

    Set outmail = Nothing
    Set outapp = Nothing

    End If
    end sub

    i know the dim as object parts are wrong and for 'objects' etc. but i don't know how to edit it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Quick VBA Question: Identify a cell and replace it's value
    By AnArtfulDodger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2014, 12:45 PM
  2. [SOLVED] SUPER QUICK:: copy Cell UP question
    By mecutemecute in forum Excel General
    Replies: 3
    Last Post: 06-09-2013, 10:27 AM
  3. [SOLVED] Quick question about automatic row deletion (should be very quick and easy!!)
    By poptart141 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-09-2013, 12:56 PM
  4. Quick question on changing the value of a cell in a range
    By manutd22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2012, 06:59 PM
  5. Quick question - quick answer about assigning shortcut keys
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2005, 06:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1