Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default 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

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
Special Copy, Paste Special macro usmc-r70 Excel Programming 3 July 2nd 09 08:12 AM
Automating copy/paste/paste special when row references change Carl LaFong Excel Programming 4 October 8th 07 06:10 AM
Paste Special If Statement [email protected] Excel Programming 10 May 21st 07 09:11 PM
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. stan-the-man Excel Worksheet Functions 7 June 14th 06 08:10 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 07:10 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"