Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Marcro to copy and paste a formula

I want to write a macro that copies and pastes a formula down column A, but I
want it to stop where column B equals "Grand Total". Can anyone help with
this?
--
Thank you, Jodie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Marcro to copy and paste a formula

Try

lngRow = Columns(2).Find("Grand Total").Row - 1
Range("A1:A" & lngRow).Formula = "=B1+C1"

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

I want to write a macro that copies and pastes a formula down column A, but I
want it to stop where column B equals "Grand Total". Can anyone help with
this?
--
Thank you, Jodie

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Marcro to copy and paste a formula

Jodie,

It would have helped if you told us what formula but this should point you
in the right direction

Sub Sonic()
r = Cells.Find(What:="Grand total", After:=Range("B1"),
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
Range("a1").Formula = "=B1"
Range("A1:A" & r).FillDown
Range("A5").Select
End Sub

Mike

"Jodie" wrote:

I want to write a macro that copies and pastes a formula down column A, but I
want it to stop where column B equals "Grand Total". Can anyone help with
this?
--
Thank you, Jodie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Marcro to copy and paste a formula

Sorry Mike, this is what I was using. I didn't know how to make it end at
"Grand Total".

Sub InsertPLANIDinCOL()
'
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "=RC[1]"
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=IF(R[-1]C[1]=""Grand Total"","""",IF(RC[1]="""",R[-1]C,RC[1]))"
Range("A2").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
End Sub

--
Thank you, Jodie


"Mike H" wrote:

Jodie,

It would have helped if you told us what formula but this should point you
in the right direction

Sub Sonic()
r = Cells.Find(What:="Grand total", After:=Range("B1"),
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row
Range("a1").Formula = "=B1"
Range("A1:A" & r).FillDown
Range("A5").Select
End Sub

Mike

"Jodie" wrote:

I want to write a macro that copies and pastes a formula down column A, but I
want it to stop where column B equals "Grand Total". Can anyone help with
this?
--
Thank you, Jodie

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Marcro to copy and paste a formula

Thank you Jacob, this worked for me.

Mike, I will try yours out as well to see which works best for my project.
--
Thank you, Jodie


"Jacob Skaria" wrote:

Try

lngRow = Columns(2).Find("Grand Total").Row - 1
Range("A1:A" & lngRow).Formula = "=B1+C1"

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

I want to write a macro that copies and pastes a formula down column A, but I
want it to stop where column B equals "Grand Total". Can anyone help with
this?
--
Thank you, Jodie

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
Excel formula to copy/paste formula needed please. colwyn Excel Discussion (Misc queries) 4 October 22nd 08 11:27 PM
can't copy/paste the formula Janis Excel Discussion (Misc queries) 2 August 14th 07 07:38 PM
Copy / Paste Formula Mark in Long Island Excel Discussion (Misc queries) 1 February 14th 07 05:27 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Marcro to copy sheet out of workbook mac Excel Programming 5 January 17th 05 10:02 PM


All times are GMT +1. The time now is 01:46 AM.

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"