PC Review


Reply
Thread Tools Rate Thread

can I force formula to be applied automatically?

 
 
DAXU
Guest
Posts: n/a
 
      12th Mar 2008
Hi,

For example, I have a excel sheet with two columns, A and B.
B's value is calculated based on A, e.g. =A1+1


My problem is that the formula is only applied to the cells selected.
I have to drag it to apply for other cells.
Is there a way that when new cell is added to column A, column B will
be automatically populated?

Many Thanks

Jerry
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      12th Mar 2008
There are two ways, EASY and HARD:

EASY:

Fill column B with:
=IF(A1="","",A1+1) and fill way down. As data get added in column A the
results appear in column B.

HARD:

Install this small worksheet event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set a = Range("A:A")
If Intersect(t, a) Is Nothing Then Exit Sub
If IsEmpty(t.Offset(0, 1).Value) Then
Application.EnableEvents = False
t.Offset(0, 1).Formula = "=A" & t.Row & "+1"
Application.EnableEvents = True
End If
End Sub
--
Gary''s Student - gsnu200773


"DAXU" wrote:

> Hi,
>
> For example, I have a excel sheet with two columns, A and B.
> B's value is calculated based on A, e.g. =A1+1
>
>
> My problem is that the formula is only applied to the cells selected.
> I have to drag it to apply for other cells.
> Is there a way that when new cell is added to column A, column B will
> be automatically populated?
>
> Many Thanks
>
> Jerry
>

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      12th Mar 2008
Gary's code won't work if you are copying and pasting multiple rows. try
this instead

Private Sub Worksheet_Change(ByVal Target As Range)
for each cell in Target
if cell.column = 1 then
If IsEmpty(cell.Offset(0, 1).Value) Then
Application.EnableEvents = False
cell.Offset(0, 1).Formula = "=A" & cell.Row & "+1"
Application.EnableEvents = True
end if
End If
next cell
End Sub

"Gary''s Student" wrote:

> There are two ways, EASY and HARD:
>
> EASY:
>
> Fill column B with:
> =IF(A1="","",A1+1) and fill way down. As data get added in column A the
> results appear in column B.
>
> HARD:
>
> Install this small worksheet event macro:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Set t = Target
> Set a = Range("A:A")
> If Intersect(t, a) Is Nothing Then Exit Sub
> If IsEmpty(t.Offset(0, 1).Value) Then
> Application.EnableEvents = False
> t.Offset(0, 1).Formula = "=A" & t.Row & "+1"
> Application.EnableEvents = True
> End If
> End Sub
> --
> Gary''s Student - gsnu200773
>
>
> "DAXU" wrote:
>
> > Hi,
> >
> > For example, I have a excel sheet with two columns, A and B.
> > B's value is calculated based on A, e.g. =A1+1
> >
> >
> > My problem is that the formula is only applied to the cells selected.
> > I have to drag it to apply for other cells.
> > Is there a way that when new cell is added to column A, column B will
> > be automatically populated?
> >
> > Many Thanks
> >
> > Jerry
> >

 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      12th Mar 2008
In Excel 2007, another way is to give a header in A1 & B1.
Select say A1:B10, and make these a "Table" via Insert > Table.
Add data in Column A.
In B2, add a Formula, and it will fill in adjacent to your data in A.
As you add data in A, the equation is automaticllly applied in B

--
HTH :>)
Dana DeLouis


"Gary''s Student" <(E-Mail Removed)> wrote in message
news:348BDE8A-7BA7-4DE5-B7CD-(E-Mail Removed)...
> There are two ways, EASY and HARD:
>
> EASY:
>
> Fill column B with:
> =IF(A1="","",A1+1) and fill way down. As data get added in column A the
> results appear in column B.
>
> HARD:
>
> Install this small worksheet event macro:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Set t = Target
> Set a = Range("A:A")
> If Intersect(t, a) Is Nothing Then Exit Sub
> If IsEmpty(t.Offset(0, 1).Value) Then
> Application.EnableEvents = False
> t.Offset(0, 1).Formula = "=A" & t.Row & "+1"
> Application.EnableEvents = True
> End If
> End Sub
> --
> Gary''s Student - gsnu200773
>
>
> "DAXU" wrote:
>
>> Hi,
>>
>> For example, I have a excel sheet with two columns, A and B.
>> B's value is calculated based on A, e.g. =A1+1
>>
>>
>> My problem is that the formula is only applied to the cells selected.
>> I have to drag it to apply for other cells.
>> Is there a way that when new cell is added to column A, column B will
>> be automatically populated?
>>
>> Many Thanks
>>
>> Jerry
>>



 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      12th Mar 2008
On Wed, 12 Mar 2008 03:33:23 -0700, Gary''s Student
<(E-Mail Removed)> wrote:

>There are two ways, EASY and HARD:


Gary's student:

There is another, even easier way, but durned if I can figure it out
completely.

Excel 2002: In one of my workbooks, in two columns of that workbook (but not
in others that also have formulas), formulas automagically get extended down
when I put a new entry into the left hand column.

I've not looked into how or why that occurs in those columns and not in others.

Under Tools/Options/Edit there is a selection item:

Extend list formats and formulas.

which is supposed to do this sort of thing.
--ron
 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      12th Mar 2008
an even easier way is to use the worksheet OFFSET function.

so if the data alone starts at sat A10 then in any other cell, say C10 put
this:
=OFFSET(A10,COUNTA(A:A)-1,,1)



"Ron Rosenfeld" wrote:

> On Wed, 12 Mar 2008 03:33:23 -0700, Gary''s Student
> <(E-Mail Removed)> wrote:
>
> >There are two ways, EASY and HARD:

>
> Gary's student:
>
> There is another, even easier way, but durned if I can figure it out
> completely.
>
> Excel 2002: In one of my workbooks, in two columns of that workbook (but not
> in others that also have formulas), formulas automagically get extended down
> when I put a new entry into the left hand column.
>
> I've not looked into how or why that occurs in those columns and not in others.
>
> Under Tools/Options/Edit there is a selection item:
>
> Extend list formats and formulas.
>
> which is supposed to do this sort of thing.
> --ron
>

 
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
Updates not applied automatically (why?) Fran Microsoft Windows 2000 Windows Updates 7 19th Jan 2006 05:19 AM
How do I define colors that are automatically applied to data seri =?Utf-8?B?NjU1Mzg=?= Microsoft Excel Charting 1 8th Jun 2005 05:42 AM
Loopback policy partly applied after restart. GPUPDATE /FORCE requ =?Utf-8?B?TWlrZSBTY2htZWl0eg==?= Microsoft Windows 2000 Active Directory 3 15th Dec 2004 09:19 PM
Re: How to remove all automatically applied styles from a datagrid? Manfred Braun Microsoft ASP .NET 3 18th Aug 2003 08:59 PM
Re: How to remove all automatically applied styles from a datagrid? Natty Gur Microsoft ASP .NET 0 18th Aug 2003 05:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:19 PM.