Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Copying and Pasting Formula

Would anyone be able to offer advise on how to do the following?

Need to be able to paste a formula =IF(COUNTBLANK(C12:H12)<6,"Y","")
into a range in a worksheet ("B12:B161") - obviously each row that it
goes down to the formula would be slightly different, e.g. Row 13
would mean the formula would change to reflect C13:H13.

The only problem is that I don't want Excel to paste this formula in
if any of the cells in the range contain a "N" or "No" so I would want
it to loop through the cells copying and pasting the formulas in each
cell (within the range) where they don't contain the "N" or "No".

As always your advise and time is really appreciated.

Many Thanks - Al Mackay ( )
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Copying and Pasting Formula

There is probably a more elegant way of doing this, but this is my brute
force method:

Sub Tester()
Set rng = Range(Cells(12, 2), Cells(161, 2))
For Each cell In rng
If cell < "N" And cell < "No" Then
cell.Formula = "=IF(COUNTBLANK(C" _
& cell.Row & ":H" & cell.Row & _
")<6," & Chr(34) & "Y" & Chr(34) _
& "," & Chr(34) & Chr(34) & ")"
End If
Next
End Sub


HTH,
Shockley



"Al Mackay" wrote in message
om...
Would anyone be able to offer advise on how to do the following?

Need to be able to paste a formula =IF(COUNTBLANK(C12:H12)<6,"Y","")
into a range in a worksheet ("B12:B161") - obviously each row that it
goes down to the formula would be slightly different, e.g. Row 13
would mean the formula would change to reflect C13:H13.

The only problem is that I don't want Excel to paste this formula in
if any of the cells in the range contain a "N" or "No" so I would want
it to loop through the cells copying and pasting the formulas in each
cell (within the range) where they don't contain the "N" or "No".

As always your advise and time is really appreciated.

Many Thanks - Al Mackay ( )



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Copying and Pasting Formula

Thanks so much for your help on this one.

Cheers - Al.

"shockley" wrote in message ...
There is probably a more elegant way of doing this, but this is my brute
force method:

Sub Tester()
Set rng = Range(Cells(12, 2), Cells(161, 2))
For Each cell In rng
If cell < "N" And cell < "No" Then
cell.Formula = "=IF(COUNTBLANK(C" _
& cell.Row & ":H" & cell.Row & _
")<6," & Chr(34) & "Y" & Chr(34) _
& "," & Chr(34) & Chr(34) & ")"
End If
Next
End Sub


HTH,
Shockley



"Al Mackay" wrote in message
om...
Would anyone be able to offer advise on how to do the following?

Need to be able to paste a formula =IF(COUNTBLANK(C12:H12)<6,"Y","")
into a range in a worksheet ("B12:B161") - obviously each row that it
goes down to the formula would be slightly different, e.g. Row 13
would mean the formula would change to reflect C13:H13.

The only problem is that I don't want Excel to paste this formula in
if any of the cells in the range contain a "N" or "No" so I would want
it to loop through the cells copying and pasting the formulas in each
cell (within the range) where they don't contain the "N" or "No".

As always your advise and time is really appreciated.

Many Thanks - Al Mackay ( )

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
How do I delete the refernce a formula when copying and pasting? Lora Excel Worksheet Functions 1 July 23rd 08 11:47 PM
copying and pasting a formula William Excel Worksheet Functions 2 November 22nd 05 12:25 AM
Trouble copying and pasting a formula Julie P. Excel Discussion (Misc queries) 6 March 4th 05 04:11 AM
Copying & Pasting Formula Connie Martin Excel Discussion (Misc queries) 2 March 3rd 05 05:11 PM
Trouble copying and pasting a formula Julie P. Excel Worksheet Functions 4 March 3rd 05 03:16 AM


All times are GMT +1. The time now is 04:49 PM.

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"