ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   search column and display results in msgbox (https://www.excelbanter.com/excel-programming/404787-search-column-display-results-msgbox.html)

Mike

search column and display results in msgbox
 
Dear All,

Thank you in advance for any help that is provided.

Following on from some of my previous posts...
I have a sheet that contains names in Column C and Dates in Column N.
I would like to have a macro start on workbook open and search for today - 2
days in column N and then look at all cells in Column C which correspond to
the value.
I would then like to view these results in a msgbox.

Cheers,

mike

JLGWhiz

search column and display results in msgbox
 
This might do it.

Private Sub Workbook_Open()
Dim c As Range
lr = Cells(Rows.Count, "N").End(xlUp).Row
sDate = CDate(Format(Now - 2, "m/d/yy"))
For Each c In Sheets(1).Range("N2:N" & lr)
If c.Value = sDate Then
MsgBox "Value in Column C for " & sDate & " is " & _
Range("C" & c.Row).Value
End If
Next
End Sub

"mike" wrote:

Dear All,

Thank you in advance for any help that is provided.

Following on from some of my previous posts...
I have a sheet that contains names in Column C and Dates in Column N.
I would like to have a macro start on workbook open and search for today - 2
days in column N and then look at all cells in Column C which correspond to
the value.
I would then like to view these results in a msgbox.

Cheers,

mike



All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com