Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I think I'd add an "Exit Sub" after the msgbox.
Or something to avoid the .offset(1,0) line. Harlan Grove wrote: wrote... I'm having problems with this and I thought it would be simple. Basicly, I want to add a value to cell A1 when the spreadsheet opens, then when its opened next add the same value to A2 and so on. I thought it would be done with a simple if statement. Nope. What you describe requires a macro, specifically either a Workbook Open macro or an Auto_Open macro. Try the following in the ThisWorkbook class module. Private Sub Workbook_Open() Const INCREMENT As Double = 1 Dim c As Range Set c = Worksheets(1).Range("A1") If Not IsEmpty(c.Value2) Then Set c = c.End(xlDown) If c.Row = c.Parent.Rows.Count Then If Not IsEmpty(c.Value2) Then MsgBox Prompt:="Column A completely filled.", Title:="ERROR" Else Set c = c.End(xlUp) End If End If Set c = c.Offset(1, 0) End If c.Value2 = c.Value2 + INCREMENT End Sub You'd then need to save the file in order for it to know to move to the next cell down in column A the next time it's opened. -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF function and null cell value | Excel Worksheet Functions | |||
cell value based on null/not null in another cell | Excel Worksheet Functions | |||
Cell to return null instead of 0 | Excel Discussion (Misc queries) | |||
cell shows 0 when referenced cell is null | Excel Worksheet Functions | |||
how to enter a null cell value in a formula | Excel Worksheet Functions |