![]() |
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 |
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"")" |
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 |
All times are GMT +1. The time now is 03:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com