Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Create Macro to copy a formula to range of cell

Excel 2000. I am a novice to this and intend to create a macro to copy a
fixed formula to a range of cell by a click of a button.

Below is the marco created but was prompted with error message when I run it.

Error message reads "Run-time error "5" : Invalid procedure cell or
argument" on the row starting with "Application.WorksheetFunction.IF....".
Please help.

Sub Macro2()
'Public strModule As String
' Macro2 Macro

Dim IsNumber As Variant
Dim Search As Variant

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A10").Select
Application.WorksheetFunction.IF(IsNumber(Search(" TOTAL", C16)),
(Right(Left(C16, Len(C16) - 1), 5)), "").Paste

Range("A10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=200
Range("A10:A200").Select
ActiveSheet.Paste
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Create Macro to copy a formula to range of cell

Hi,

No sure exactly what you need to do from your code, but see the part I
replaced. You don't want to use the "application.worlsheetfunction" method.
That is for when you want to use an excel function to manipulate a value in
your code.

Hopefully this will get you on the right track.

Sub Macro2()
'Public strModule As String
' Macro2 Macro

Dim IsNumber As Variant
Dim Search As Variant

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A10").Select


ActiveCell.FormulaR1C1 = _
"=IF(ISNUMBER(SEARCH(""TOTAL"", R[11]C[-1])),(RIGHT(LEFT(R[11]C[-1],
LEN(R[11]C[-1]) - 1), 5)), """")"


Range("A10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=200
Range("A10:A200").Select
ActiveSheet.Paste
End Sub

"summer" wrote in message
...
Excel 2000. I am a novice to this and intend to create a macro to copy a
fixed formula to a range of cell by a click of a button.

Below is the marco created but was prompted with error message when I run
it.

Error message reads "Run-time error "5" : Invalid procedure cell or
argument" on the row starting with "Application.WorksheetFunction.IF....".
Please help.

Sub Macro2()
'Public strModule As String
' Macro2 Macro

Dim IsNumber As Variant
Dim Search As Variant

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A10").Select
Application.WorksheetFunction.IF(IsNumber(Search(" TOTAL", C16)),
(Right(Left(C16, Len(C16) - 1), 5)), "").Paste

Range("A10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=200
Range("A10:A200").Select
ActiveSheet.Paste
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Create Macro to copy a formula to range of cell

I wasn't specific.
Actually needs to copy a "If" formula to the cell when the formula search
and found the word "Total" in column C
I have tried your advise but couldn't get the formula pasted on the cell.
Your help again please.

"AD108" wrote:

Hi,

No sure exactly what you need to do from your code, but see the part I
replaced. You don't want to use the "application.worlsheetfunction" method.
That is for when you want to use an excel function to manipulate a value in
your code.

Hopefully this will get you on the right track.

Sub Macro2()
'Public strModule As String
' Macro2 Macro

Dim IsNumber As Variant
Dim Search As Variant

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A10").Select


ActiveCell.FormulaR1C1 = _
"=IF(ISNUMBER(SEARCH(""TOTAL"", R[11]C[-1])),(RIGHT(LEFT(R[11]C[-1],
LEN(R[11]C[-1]) - 1), 5)), """")"


Range("A10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=200
Range("A10:A200").Select
ActiveSheet.Paste
End Sub

"summer" wrote in message
...
Excel 2000. I am a novice to this and intend to create a macro to copy a
fixed formula to a range of cell by a click of a button.

Below is the marco created but was prompted with error message when I run
it.

Error message reads "Run-time error "5" : Invalid procedure cell or
argument" on the row starting with "Application.WorksheetFunction.IF....".
Please help.

Sub Macro2()
'Public strModule As String
' Macro2 Macro

Dim IsNumber As Variant
Dim Search As Variant

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A10").Select
Application.WorksheetFunction.IF(IsNumber(Search(" TOTAL", C16)),
(Right(Left(C16, Len(C16) - 1), 5)), "").Paste

Range("A10").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=200
Range("A10:A200").Select
ActiveSheet.Paste
End Sub





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: Macro Copy Active Cell to Range Name, loop [email protected] Excel Programming 3 March 30th 07 08:25 PM
I need formula help or create a macro to copy and paste value only Rebecca Excel Discussion (Misc queries) 4 April 8th 06 01:18 PM
create formula to compare cell 1 with a range of cell KKXC Excel Programming 2 January 7th 06 06:37 AM
How to copy formula from one cell to a range? Jason Weiss Excel Programming 1 April 22nd 05 03:54 PM
create a macro to copy/paste cell data joshua.v Excel Programming 1 September 14th 04 04:42 PM


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