Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default add value to cell if cell is not null

Hi

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.

Any help is welcome.

cheers

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 38
Default add value to cell if cell is not null

It would probably be easiest to do this with a macro - naming the
macro auto_open will invoke the macro when the workbook is opened.

Use an IF in the macro to make sure it's not empty, and then once
there is some data you can use the Selection.End(xlDown).Select
command to find the last item in the list and just move down one.

On Mar 5, 12:21 pm, wrote:
Hi

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.

Any help is welcome.

cheers


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default add value to cell if cell is not null

On 5 Mar, 17:48, wrote:
It would probably be easiest to do this with a macro - naming the
macro auto_open will invoke the macro when the workbook is opened.

Use an IF in the macro to make sure it's not empty, and then once
there is some data you can use the Selection.End(xlDown).Select
command to find the last item in the list and just move down one.

On Mar 5, 12:21 pm, wrote:



Hi


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.


Any help is welcome.


cheers- Hide quoted text -


- Show quoted text -


I dont want this to be visible on screen , I want it in a hidden
sheet. Its basicly going to be used as a tacker to see how often this
SS is being used.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default add value to cell if cell is not null

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.
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default add value to cell if cell is not null

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF function and null cell value DAllen Excel Worksheet Functions 2 February 19th 07 04:48 PM
cell value based on null/not null in another cell spence Excel Worksheet Functions 1 February 18th 06 11:49 PM
Cell to return null instead of 0 dford Excel Discussion (Misc queries) 7 November 28th 05 06:37 PM
cell shows 0 when referenced cell is null dee Excel Worksheet Functions 8 October 6th 05 01:39 PM
how to enter a null cell value in a formula Using formulas to enter NULL cell values Excel Worksheet Functions 5 December 16th 04 03:29 AM


All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"