Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
 
Posts: n/a
Default Insert Formula and Copy to other cells

Hello,
I need help fast! I need to be able to insert a Formula into rows that
contain certain text. I then need to be able to copy all this formula
across 15 columns and down to the end of the active workbook for each
row that contains this criteria. I want the formula to automatically
update to the correct cell reference. My formula is rather lengthy but
it works perfectly in a 'normal' spreadsheet without running a macro.

This is what I have:

Dim intx as Integer
Dim lngrow as long

ActiveCell.SpecialCells(xlLastCell).Select
lngrow = ActiveCell.Row 'lastcell in spreadsheet

For intx = 1 To lngrow
Cells(intx, 1).Select
If InStr(1, ActiveCell.Value, " Target Renewal") 0
Then
Range(Cells(intx, 6), Cells(intx, 20)).Select
Selection.Formula =
"=IF(AND(OR($D$2=30,$D$2=60),D15=""aprent"")," -
",IF(OR(E19=$B$2*(1-($D$2/30)),E19=$B$2*(1-(($D$2-30)/30)),E19=$B$2*(1-(($D$2-60)/30)),E19=$B$2*(1-(($D$2-90)/30)),E19=$B$2),$B$2,IF((F15+$D$2)<30,$B$2*(1-($D$2/30)),IF(OR(D15=""aprent"",F150),"
- ",IF((F15+E15+$D$2)<60,$B$2*(1-(($D$2-30)/30)),IF(D19=""," -
",IF((D15+E15+F15+$D$2)<90,$B$2*(1-(($D$2-60)/30))," - ")))))))"
End If
Next

Any help is appreciated. Thanks!

  #2   Report Post  
Dave O
 
Posts: n/a
Default

How about this:
Sub YourCodeName()
Range("a1").Select '<-- The cell that contains the formula you need to
copy
Selection.Copy '<--copy into clipboard

For intx = 1 To lngrow '<--start your For loop as usual
Cells(intx, 1).Select
If InStr(1, ActiveCell.Value, " Target Renewal") 0 Then
Range(Cells(intx, 6), Cells(intx, 20)).Select
ActiveSheet.Paste
Endif
Next Intx

.... or something like that?

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
Rounding formula won't copy to other cells in column - why? LindaO Excel Discussion (Misc queries) 4 July 11th 05 10:57 PM
How to copy and paste same formula in multiple cells? Amanda Excel Worksheet Functions 1 June 30th 05 04:16 PM
How to copy cells with keeping exact formula intact Stephen Excel Discussion (Misc queries) 6 April 3rd 05 10:56 PM
How do you copy a cell's content verses it's formula? Tammy Excel Discussion (Misc queries) 1 March 2nd 05 06:30 PM
to copy a formula in cell c1 (+b1/b11) to cells c2-10, how can i . bvi Excel Worksheet Functions 3 December 23rd 04 06:14 PM


All times are GMT +1. The time now is 05:50 PM.

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"