![]() |
Paste Special If statement
I'm trying to write code for a paste special if statement and need help. I
want it to perform like this: If C1 (calculated from other formula) is equal to 1, then paste that value into D1, if it is equal to 0, then do nothing. I'm trying to get a column that identifies which items in the first column were ever calculated to equal one and then apply conditional formatting. Thanks |
Paste Special If statement
Put the following worksheet event macro in the worksheet code area:
Private Sub Worksheet_Calculate() If Range("C1").Value = 1 Then Range("D1").Value = 1 End If End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200902 "Jeremy" wrote: I'm trying to write code for a paste special if statement and need help. I want it to perform like this: If C1 (calculated from other formula) is equal to 1, then paste that value into D1, if it is equal to 0, then do nothing. I'm trying to get a column that identifies which items in the first column were ever calculated to equal one and then apply conditional formatting. Thanks |
Paste Special If statement
Yea, I had tried that before and it didn't work, still can't seem to.
I have pasted the code, put a 1 in the cell C1, I saved the book, hit F9 to calculate etc and nothing. "Gary''s Student" wrote: Put the following worksheet event macro in the worksheet code area: Private Sub Worksheet_Calculate() If Range("C1").Value = 1 Then Range("D1").Value = 1 End If End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200902 "Jeremy" wrote: I'm trying to write code for a paste special if statement and need help. I want it to perform like this: If C1 (calculated from other formula) is equal to 1, then paste that value into D1, if it is equal to 0, then do nothing. I'm trying to get a column that identifies which items in the first column were ever calculated to equal one and then apply conditional formatting. Thanks |
Paste Special If statement
Nevermind, I got it. I think there was an old definition or something in
there. I deleted the cells instead of just clearing and it worked fine. Thanks! "Gary''s Student" wrote: Put the following worksheet event macro in the worksheet code area: Private Sub Worksheet_Calculate() If Range("C1").Value = 1 Then Range("D1").Value = 1 End If End Sub Because it is worksheet code, it is very easy to install and use: 1. right-click the tab name near the bottom of the window 2. select View Code - this brings up a VBE window 3. paste the stuff in and close the VBE window If you save the workbook, the macro will be saved with it. To remove the macro: 1. bring up the VBE windows as above 2. clear the code out 3. close the VBE window To learn more about Event Macros (worksheet code), see: http://www.mvps.org/dmcritchie/excel/event.htm -- Gary''s Student - gsnu200902 "Jeremy" wrote: I'm trying to write code for a paste special if statement and need help. I want it to perform like this: If C1 (calculated from other formula) is equal to 1, then paste that value into D1, if it is equal to 0, then do nothing. I'm trying to get a column that identifies which items in the first column were ever calculated to equal one and then apply conditional formatting. Thanks |
All times are GMT +1. The time now is 12:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com