ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Function to return column where a date is entered (https://www.excelbanter.com/excel-programming/395287-function-return-column-where-date-entered.html)

Barb Reinhardt[_3_]

Function to return column where a date is entered
 
I'd like to have a function something like this:

Function FindDateColumn(myWS as worksheet, myDate as Date)

I want to find the first (and probably only entry) of a specific date on a
worksheet and return the date column. I can't seem to get it to return
anything. I'd show my code, but unfortunately, it's at work and I"m not.
It seems to be format specific somehow. Can someone help?

Thanks,
Barb Reinhardt



joel

Function to return column where a date is entered
 
If you are passing a worksheet from the spreadsheet to VBA its best to pass
the string name. try this code

Function FindDateColumn(myWS As String, myDate As Date)

Worksheets(myWS).Select
FindDateColumn = _
Selection.Find(what:=myDate, LookIn:=xlValues)

End Function


"Barb Reinhardt" wrote:

I'd like to have a function something like this:

Function FindDateColumn(myWS as worksheet, myDate as Date)

I want to find the first (and probably only entry) of a specific date on a
worksheet and return the date column. I can't seem to get it to return
anything. I'd show my code, but unfortunately, it's at work and I"m not.
It seems to be format specific somehow. Can someone help?

Thanks,
Barb Reinhardt





All times are GMT +1. The time now is 05:39 PM.

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