PC Review


Reply
Thread Tools Rate Thread

adding 1 to previous cell value using code

 
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      8th Oct 2007
Hi,
In 'B', I would like the next empty cell to be automatically filled using
the data from the cell above and adding 1.
For instance, when text is entered somewhere in column 'C', in the
corresponding cell in 'B' I'd like "07/***" to show where "07/" is formatted
(to show the year) and "***" would be the next sequential number after the
cell above it.

I'd like it incorporated into this code which adds date to 'A':

Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C6:C3000")) Is Nothing Then
With Target
If .Value <> "" Then
.Offset(0, -1).Value = ***cell above plus 1***
Application.EnableEvents = True
.Offset(0, -2).Value = Format(Date, "dd/mmm/yy")
End If

Thanks for your thoughts
--
Traa Dy Liooar

Jock
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Qm9iIFVtbGFzLCBFeGNlbCBNVlA=?=
Guest
Posts: n/a
 
      8th Oct 2007
You don't need ANY VBA to do this
Format the column as "07/"General
put this formula in A2, for example:
=MAX($A$1:A1)+1
If you're in cell A10, this formula would read =MAX($A$1:A9)+1.
Wherever this formula appears, it'll be one more than the previous entry!
Bob Umlas
Excel MVP

"Jock" wrote:

> Hi,
> In 'B', I would like the next empty cell to be automatically filled using
> the data from the cell above and adding 1.
> For instance, when text is entered somewhere in column 'C', in the
> corresponding cell in 'B' I'd like "07/***" to show where "07/" is formatted
> (to show the year) and "***" would be the next sequential number after the
> cell above it.
>
> I'd like it incorporated into this code which adds date to 'A':
>
> Application.EnableEvents = False
> If Not Intersect(Target, Me.Range("C6:C3000")) Is Nothing Then
> With Target
> If .Value <> "" Then
> .Offset(0, -1).Value = ***cell above plus 1***
> Application.EnableEvents = True
> .Offset(0, -2).Value = Format(Date, "dd/mmm/yy")
> End If
>
> Thanks for your thoughts
> --
> Traa Dy Liooar
>
> Jock

 
Reply With Quote
 
=?Utf-8?B?Sm9jaw==?=
Guest
Posts: n/a
 
      8th Oct 2007
Thanks Bob. Had to adapt it as I only require next number to appear when
there was text in 'C'

Cheers
--
Traa Dy Liooar

Jock


"Bob Umlas, Excel MVP" wrote:

> You don't need ANY VBA to do this
> Format the column as "07/"General
> put this formula in A2, for example:
> =MAX($A$1:A1)+1
> If you're in cell A10, this formula would read =MAX($A$1:A9)+1.
> Wherever this formula appears, it'll be one more than the previous entry!
> Bob Umlas
> Excel MVP
>
> "Jock" wrote:
>
> > Hi,
> > In 'B', I would like the next empty cell to be automatically filled using
> > the data from the cell above and adding 1.
> > For instance, when text is entered somewhere in column 'C', in the
> > corresponding cell in 'B' I'd like "07/***" to show where "07/" is formatted
> > (to show the year) and "***" would be the next sequential number after the
> > cell above it.
> >
> > I'd like it incorporated into this code which adds date to 'A':
> >
> > Application.EnableEvents = False
> > If Not Intersect(Target, Me.Range("C6:C3000")) Is Nothing Then
> > With Target
> > If .Value <> "" Then
> > .Offset(0, -1).Value = ***cell above plus 1***
> > Application.EnableEvents = True
> > .Offset(0, -2).Value = Format(Date, "dd/mmm/yy")
> > End If
> >
> > Thanks for your thoughts
> > --
> > Traa Dy Liooar
> >
> > Jock

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding one to the number from the previous cell with text... T. Microsoft Excel Misc 8 14th Oct 2009 03:03 AM
Adding calculated value to previous cell electricbluelady Microsoft Excel Misc 3 26th Jun 2008 08:06 PM
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell suyash.nathani@gmail.com Microsoft Excel Worksheet Functions 2 7th Nov 2007 09:39 AM
Re: adding a code to a cell? Brad Microsoft Excel Programming 0 11th Apr 2006 02:53 PM
adding a code to a cell? Brad Microsoft Excel Programming 2 4th Apr 2006 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 AM.