Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Creating Loop to Paste Array

I currently have a macro that copy pastes a formula based on a predetermined
cell range. Is there a way to create a loop that will find cells that have
values in Col B and Col C and paste the formula in Col N.

Macro Example: (Replace "=Range("N2:N100)) with loop.

ActiveCell.FormulaR1C1 = _
"=IF(RC13="""","""",SUMIF(R2C2:R500C2,R2C13:R100C1 3,R2C3:R500C3))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N100"), Type:=xlFillDefault
Range("N2:N100").Select
ActiveWindow.ScrollRow = 1

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Creating Loop to Paste Array

dim myCell as range
with activesheet
for each mycell in .range("n2:n100")
if isempty(.cells(mycell.row,"B")) _
and isempty(.cells(mycell.row,"C")) then
'both empty, do nothing
else
mycell.formular1c1 = "yourformulahere"
end if
next mycell
end with

===
I wasn't sure if both B and C had to be empty or just one (or the other).

Change that AND to Or if you want.

Nate wrote:

I currently have a macro that copy pastes a formula based on a predetermined
cell range. Is there a way to create a loop that will find cells that have
values in Col B and Col C and paste the formula in Col N.

Macro Example: (Replace "=Range("N2:N100)) with loop.

ActiveCell.FormulaR1C1 = _
"=IF(RC13="""","""",SUMIF(R2C2:R500C2,R2C13:R100C1 3,R2C3:R500C3))"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N100"), Type:=xlFillDefault
Range("N2:N100").Select
ActiveWindow.ScrollRow = 1

Thanks


--

Dave Peterson
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
Help with creating a loop Woodi2 Setting up and Configuration of Excel 1 April 19th 09 09:10 PM
creating a loop JakeShipley2008 Excel Discussion (Misc queries) 2 September 9th 08 02:17 PM
Need Help With Creating A Loop zero635[_8_] Excel Programming 3 October 29th 05 08:58 PM
Excel VBA, Loop, array, cut and paste [email protected] Excel Programming 1 September 23rd 05 06:40 PM
Creating a For Loop Justin Ragsdale Excel Programming 5 May 23rd 04 10:40 PM


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