![]() |
Simple if formula in a macro
Hi folks,
I have a very simple request, but my VBA days are way gone and I dont really know how it works with excell. All I need is a IF statement that checks cell A26 to see if it is empty or if it includes a date entry (IE nov/11). If the cell is empty or if the date is equal to at least today then do nothing. If the date in the cell is older than todays date, then call sub routine and put today date on cell a26. Thats it. I plan on assigning this macro to a button, but it would be better if this routine was run automatically everytime the worksheet was opened, how is it done? Thanks |
Simple if formula in a macro
Thanks,
It works. How do you make it so that it autoruns when the worksheet is opened? Thanks again. Dave Peterson wrote: Option Explicit Sub Auto_Open() Dim myCell As Range Dim wks As Worksheet Set wks = ThisWorkbook.Worksheets("sheet1") Set myCell = wks.Range("a26") If IsEmpty(myCell.Value) Then myCell.Value = Date ElseIf IsDate(myCell.Value) Then If myCell.Value < Date Then myCell.Value = Date End If End If End Sub If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm wrote: Hi folks, I have a very simple request, but my VBA days are way gone and I dont really know how it works with excell. All I need is a IF statement that checks cell A26 to see if it is empty or if it includes a date entry (IE nov/11). If the cell is empty or if the date is equal to at least today then do nothing. If the date in the cell is older than todays date, then call sub routine and put today date on cell a26. Thats it. I plan on assigning this macro to a button, but it would be better if this routine was run automatically everytime the worksheet was opened, how is it done? Thanks -- Dave Peterson |
All times are GMT +1. The time now is 02:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com