Adding a row on Open
Hi everyone, This might seem trivial to many but I don't seem to understand it why I am having trouble with this. I have the following code Code: -------------------- Private Sub Workbook_Open() Private Sub Workbook_Open() Dim Today As String Today = "=Today()" With Worksheets(4) If .Cells(4, 1).Value < Today Then Rows("4:4").Insert Shift:=xlDown .Cells(4, 1) = Today End If End With End Sub -------------------- As you can see, I want to compare a cell with today's date. If it's not today's date, then add a new row (since data will be added). The code looks correct to me, but I don't doubt something is wrong since it obviously is not working properly. Everytime I open the workbook, it adds a new row regardless whether cell A4 has today's date or not. Does anyone have any insight as to what may be going on? Thanks in advance. -- Isaac -- I Maycotte ------------------------------------------------------------------------ I Maycotte's Profile: http://www.excelforum.com/member.php...o&userid=35604 View this thread: http://www.excelforum.com/showthread...hreadid=557836 |
Adding a row on Open
Sorry. Clearly, there is only one "Private Sub Workbook_Open()" in th code. Ignore one of them (since it is not in my code). -- Isaa -- I Maycott ----------------------------------------------------------------------- I Maycotte's Profile: http://www.excelforum.com/member.php...fo&userid=3560 View this thread: http://www.excelforum.com/showthread.php?threadid=55783 |
Adding a row on Open
Thanks a lot Gary! The issue was resolved as soon as I put the '.' in front of my code. -- Isaac -- I Maycotte ------------------------------------------------------------------------ I Maycotte's Profile: http://www.excelforum.com/member.php...o&userid=35604 View this thread: http://www.excelforum.com/showthread...hreadid=557836 |
All times are GMT +1. The time now is 08:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com