find last occurence of x

jarhead58

Board Regular
Hello everyone!

I'm looking for the easiest way to find the last time "X" occured in a column via a module I'm calling test for now. Specifically, find the last time "X" occurs in col g on sheet2 lets say, if true, offset(7, 0) and then put "X" in that cell from the offset. TIA
 

Rick Rothstein

MrExcel MVP
Try this in your macro...

Sheets("Sheet2").Columns("G").Find("X", , , xlWhole, , xlPrevious, False, , False).Offset(7) = "X"
 
Last edited:

jarhead58

Board Regular
Try this in your macro...

Sheets("Sheet2").Columns("G").Find("X", , , xlWhole, , xlPrevious, False, , False).Offset(7) = "X"
Thank you so much for that! I tried doing something with a For Next but it kept erroring.

Now also have dates in column a starting at row 2 on the same page. Would I use something like, If sheets("sheet2").range("G2:G26").value <> "X" AND
sheets("sheet2").range("A2:A26") = TODAY() Then, not sure how to format this, make this cell value "X". Would that work
 

jarhead58

Board Regular
Sorry about that! The intersecting cell of Today() in col A and col G, eg, A6 and G6
 

Rick Rothstein

MrExcel MVP
Sorry about that! The intersecting cell of Today() in col A and col G, eg, A6 and G6
Will a cell equal to TODAY() appear only once in Column A or could today's date appear more than once in Column A?

If more than once, are we supposed to put the "X" in Column G for only the last today date for do it for all the today dates?
 

jarhead58

Board Regular
Will a cell equal to TODAY() appear only once in Column A or could today's date appear more than once in Column A?

If more than once, are we supposed to put the "X" in Column G for only the last today date for do it for all the today dates?
Just once and thank you for the reply and time sir!
 

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Macro to copy values across rows and transposing them and add the user id
    [FONT=Times New Roman][SIZE=3][COLOR=#000000][/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]Hi,[/COLOR][/SIZE][/FONT] [FONT=Times New...
Top