Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default dynamically change IF formula in macro, possible?

I'm trying to calculate percentages that a column of values are of a
single cell value, e.g.
column a contains values 10 through 100
column b will contain the percentage that a is of a cell C6
I'm trying to populate the cell formulas in column B with an =IF(...
formula, is that possible, I tried this

for n = 1 to 10
Cells(n, 2).Formula = "=IF(C6, Cells(n, 1).Value / cells(6,3).value &
, 0)"
next

But that won't work, I've tried a few other things, I want the sheet to
update when different values are entered into C6, with the percentages
if C6 is not empty, and with 0's if c6 is empty.

Does anyone have any suggestions?

TIA,
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default dynamically change IF formula in macro, possible?

You won't be able to use a .value in the value of a cell I don't think. Here is a snippet of code that I used recently where I put an if statement in a cell.

Sheet5.Cells(row_tag + 1, col_tag + 1).Value = "=IF('Introduction'!B7<"""",'Introduction'!B7 , ""N/A"")"
Sheet5.Cells(row_tag + 3, col_tag + 1).Value = "=IF('LoTo Procedure #" & page_number & "'!C" & cell_data & "<"""",'LoTo Procedure #" & page_number & "'!C" & cell_data & ", ""N/A"")"
Sheet5.Cells(row_tag + 5, col_tag + 1).Value = "=IF('LoTo Procedure #" & page_number & "'!B" & cell_data & "<"""",'LoTo Procedure #" & page_number & "'!B" & cell_data & ", ""N/A"")"
Sheet5.Cells(row_tag + 21, col_tag + 1).Value = "=IF('LoTo Procedure #" & page_number & "'!D" & cell_data & "<"""",'LoTo Procedure #" & page_number & "'!D" & cell_data & ", ""N/A"")"
Sheet5.Cells(row_tag + 25, col_tag + 1).Value = "=IF('LoTo Procedure #" & page_number & "'!F" & cell_data & "<"""",'LoTo Procedure #" & page_number & "'!F" & cell_data & ", ""N/A"")"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default dynamically change IF formula in macro, possible?

Perhaps...

In B10:
=IF($C$6,$A10/$C$6,0)

...and copy down!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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
change formula dynamically geebee Excel Programming 1 December 20th 07 04:50 PM
How can I dynamically change a file link in a formula? GTX Excel Worksheet Functions 2 October 31st 07 11:21 PM
Macro Copying Rows That Change Dynamically Bill Lowry Excel Programming 2 September 28th 07 06:20 PM
Dynamically Change date in Formula Midget Excel Worksheet Functions 3 February 9th 07 03:35 AM
Dynamically change cell range in formula by background color? [email protected] Excel Programming 1 January 9th 06 10:08 PM


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

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

About Us

"It's about Microsoft Excel"