View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chris Scott Chris Scott is offline
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"")"