Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding formulas to cells dependant on data in another cell.

Hello All,

I have a 10 formulas that operate along an Excel row. Initially I had
copied the formulas into all rows in a spreadsheet up to row 3000.

However this makes my spreadsheet unnecessarily large. What I would
therefore like to do is copy the formulas ONLY if data is added into
the first column.

Is this possible using VBA?

For example if I have the formula =A1+B1 operating in cell C1 how
could I copy the formula ONLY when data is added to cell s in column
‘A’?

Regards,

Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Adding formulas to cells dependant on data in another cell.

In the left panel of your VB Editor there is a list of your Worksheets under
a heading Microsoft Excel Objects. Click on the sheet where you want to
apply this action. then in the right panel, paste the following code.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing _
And Target.Offset(0, 1) < "" Then 'see if col B has data
'copy the formulas in col C:L down one row
Range(Target.Offset(0, 2), Target.Offset(0, 12)).FillDown

End If
End Sub

You may need to adjust the Range("A:A") so to something like Range("A3"A3000")
Be sure that you do not have other data or formulas in the col C:L that
would get overwritten. It is best to keep this worksheet "dedicated" to this
one task, without cluttering it up. The macro will run EVERY time you enter
something in any cell in this worksheet, hence the first line of code in the
macro.

"KevinC" wrote:

Hello All,

I have a 10 formulas that operate along an Excel row. Initially I had
copied the formulas into all rows in a spreadsheet up to row 3000.

However this makes my spreadsheet unnecessarily large. What I would
therefore like to do is copy the formulas ONLY if data is added into
the first column.

Is this possible using VBA?

For example if I have the formula =A1+B1 operating in cell C1 how
could I copy the formula ONLY when data is added to cell s in column
€˜A?

Regards,

Kevin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding formulas to cells dependant on data in another cell.

Hi cush,

That seems to work.

There is one limitation with the code however (for my purposes that
is).

If the user does not enter any data in column A then no formulas are
copied to the following row. In my spreadsheet it is possible that
they user may not need to/or may forget to add data into column A.

No that I think about it I guess I need some code that says something
along the lines of:

"If there is any data in a row apply the following formulas:
- in colum C find the result of A*B
- in colum E find the result of A/B
- etc..."

I think what I was hoping I might be able to do is to write the
formulas in VBA and then apply them if there is data in the row.

Does this make sense? any idea if it is possible?

Thanks,

Kevin
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding formulas to cells dependant on data in another cell.

Still got no where with this, so if anyone can help I would be
greatful!
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
Adding cells with formulas Amy Excel Worksheet Functions 2 November 10th 09 05:14 PM
Data in Cell dependant on drop down lists kalahari New Users to Excel 1 April 2nd 08 05:40 AM
Adding formulas to cells Jordan Excel Programming 7 May 17th 06 04:23 AM
adding to different totals dependant upon selection from drop down Shaunnyb Excel Worksheet Functions 0 April 4th 06 10:00 PM
Disable a checkbox dependant upon cell data frendabrenda1 Excel Discussion (Misc queries) 1 September 2nd 05 02:03 PM


All times are GMT +1. The time now is 08:09 AM.

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"