+ Reply to Thread
Results 1 to 6 of 6

VBA- how to check within a row within a range- completely stuck! :(

  1. #1
    Registered User
    Join Date
    09-10-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    3

    VBA- how to check within a row within a range- completely stuck! :(

    Hi guys- i'm quite new to vba and i've been following some of the guidance on this site which has been really useful. Unfortunately i'm just really stuck on something.
    1.jpg

    I have produced a spreadsheet where I enter checkmarks (as an "X") and it cycles through the columns and when it finds an X (with no "sent" alongside) it composes an email to an address on the same row in addition to adding a "sent" to the next column. My code is below

    x = 9 'column I'

    For x = 9 To 35

    For Each Cell In Columns(x).Cells.SpecialCells(xlCellTypeConstants)

    If Cell.Value = "X" And Cell.Offset(, 2).Value <> "sent" Then
    Cell.Offset(, 2).Value = "sent"

    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .Display
    .to = Cells(Cell.Row, "E")
    .CC = Cells(Cell.Row, "F")
    .Subject =
    .HTMLBody = strbody & Cells(Cell.Row, "D") & "," & "<br><br>" & strbody1 & Cells(3, Cell.Column) & strbody2 & .HTMLBody

    .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    End If
    Next Cell
    Next x

    This works really well but I need to add another thing which I just cant seem to do. In the email I now need to compile a list of the previous "X" in terms of the dates (in the displayed example it would be 01 Oct but if there were more than one X on the row all those dates need to be listed). I've tried some ideas but nothing seems to work within my existing code.

    Any suggestions?

  2. #2
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: VBA- how to check within a row within a range- completely stuck! :(

    Hello and welcome to the forum.

    First, your code should be in code brackets - select the code and click the # button.

    Second, you will get faster & better responses if you attach a file, so we don't have to recreate your structure or guess at various options you might have / have not included.

    For your question, is it just the list of dates on the same row? Or anywhere in the sheet?
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  3. #3
    Registered User
    Join Date
    09-10-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA- how to check within a row within a range- completely stuck! :(

    Hi, Thank you very much for responding.

    Please find my excel sheet attached.

    This sheet records absences over a period of several of weeks.
    Each week I input the absences with a "X" and run the code. This checks the sheet for "X"'s then batch generates emails to absent individuals.
    It also puts a "sent" next to the "X" so when the code is run again the absences already emailed are not picked up again.

    The additional functionality i'm trying to add is that each email sent to an absentee should also contain a list of previous absences (if any) at the bottom but annoyingly all my attempts to do this have failed so far.

    Please also find attached an image of what I ideally want to happen. Any advice or suggestions would be most appreciated!
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: VBA- how to check within a row within a range- completely stuck! :(

    Try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-10-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA- how to check within a row within a range- completely stuck! :(

    This works perfectly! thank you so much!!

  6. #6
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: VBA- how to check within a row within a range- completely stuck! :(

    See attached file.
    Attached Files Attached Files

+ 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. Completely stuck on this Scoring Spreadsheet :(
    By prisoner in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-13-2015, 01:18 PM
  2. [SOLVED] Formula to check multiple values?! I'm stuck! :(
    By Miss Molko in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-15-2014, 06:54 AM
  3. [SOLVED] How to remove a deleted named range completely
    By megaiooo in forum Excel General
    Replies: 8
    Last Post: 08-16-2013, 09:01 PM
  4. [SOLVED] CSng <Subscript out of range> - Completely Stumped
    By skania in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-10-2013, 08:01 AM
  5. [SOLVED] check an column if anything matches completely
    By itzmemike in forum Excel General
    Replies: 3
    Last Post: 04-03-2012, 02:45 PM
  6. Dynamic range formula not counting completely
    By TK5 in forum Excel General
    Replies: 5
    Last Post: 07-08-2008, 10:11 AM
  7. need urgent help: completely lost/stuck with vlookup issue
    By jimmyjj in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-19-2006, 10:35 PM

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