Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have an Excel 2007 spreadsheet that has an index number in cell AJ1. At
this time, the number is "40606" Each time the spreadsheet is opened, I need the number to increase by 1. So that the next time the sheet is opened, the index number would be "40607" and so on. Any help would be greatly appreciated. -- Lineman |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If a user opens the workbook and closes without saving, does the cell get
incremented? If yes, you'll want to save as soon as the cell is updated. This code (with hardly any validity checks) would go in a General module: Option Explicit Sub auto_open() Dim myCell As Range With ThisWorkbook Set myCell = .Worksheets("Sheetnamehere!").Range("AJ1") End With With myCell If IsNumeric(.Value) Then .Value = .Value + 1 Else 'what should happen? reset the counter? .Value = 1 End If End With ThisWorkbook.Save 'save right away???? End Sub If you're new to macros: Debra Dalgleish has some notes how to implement macros he http://www.contextures.com/xlvba01.html David McRitchie has an intro to macros: http://www.mvps.org/dmcritchie/excel/getstarted.htm Ron de Bruin's intro to macros: http://www.rondebruin.nl/code.htm (General, Regular and Standard modules all describe the same thing.) Lineman116 wrote: I have an Excel 2007 spreadsheet that has an index number in cell AJ1. At this time, the number is "40606" Each time the spreadsheet is opened, I need the number to increase by 1. So that the next time the sheet is opened, the index number would be "40607" and so on. Any help would be greatly appreciated. -- Lineman -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Additional info that should have been included in my first posting. My bad.
Following is the macro that was used in Excel 2003. It does not work after being copied into the 2007 Excel file. I changed the specified cell information as the new (2007) sheet changed. Sub Workbook_Open() Sheets("Sheet1").Range("K1") = _ Sheets("Sheet1").Range("K1").Value + 1 End Sub Would it be a version conflict that is causing this macro to not work in Excel 2007? -- Lineman "Lineman116" wrote: I have an Excel 2007 spreadsheet that has an index number in cell AJ1. At this time, the number is "40606" Each time the spreadsheet is opened, I need the number to increase by 1. So that the next time the sheet is opened, the index number would be "40607" and so on. Any help would be greatly appreciated. -- Lineman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
How do I set up a "roll over" counter in excel 2003? | Excel Worksheet Functions | |||
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" | Excel Discussion (Misc queries) | |||
Need help with "Headline Counter" spreadsheet... | Excel Discussion (Misc queries) | |||
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" | Excel Discussion (Misc queries) |