Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to copy formula to all rows that contain data in columns A:C

I tried posting this over in a VBScripting group and they suggesting
coming here, instead. Some additional background:

I found the original macro posted by Tom Olgilvy, but it was posting a
simple sum formula. Substituting the more complex array formula below
broke the function. I was able to get the function to paste, but not
operate as an array formula. Any help would be much appreciated.

Jason

The original post:
I'm trying to make a command button on an Excel sheet that will add a
function to column D whenever there is data in columns A:C. So far, I
have the following:

Dim rng As Range
With Worksheets("Shop Log")
Set rng = .Range(.Cells(1, 3), .Cells(Rows.Count, 3).End(xlUp))
End With
rng.Offset(0, 1).Formula =
"{=MID(C2,MATCH(FALSE,ISERROR(1*MID(C2,ROW(INDIREC T("1:"&LEN(C2))),1)),0),LEN(C2)-SUM(1*ISERROR(1*MID(C2,ROW(INDIRECT("1:"&LEN(C2))) ,1))))*1}"
End Sub

The double quote in the INDIRECT functions causes a compile error,
Expected: end of statement. I assume this is because of the leading
quote after "Formula =", but I don't know how to fix this. Any help
would be much appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Macro to copy formula to all rows that contain data in columns A:C

Hi Jason,

Apparently the rule is to double up the internal quotes, so for each of
the INDIRECTS change to ""1:"". That got rid of the "Expected end of
statement error".

Also, I think you don't include the "{" and "}" in the formula, I think
you use
"FormulaArray = "=MID(etc" instead of Formula = "{=Mid(etc"


Ken Johnson

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
macro to select and copy rows only containing data shaz0503 Excel Discussion (Misc queries) 5 October 10th 08 01:58 AM
Macro simplifying - copy rows to worksheets based on values in 2 different columns markx Excel Programming 1 February 27th 06 03:36 PM
Copy Data to Rows instead of Columns Donnie Stone Excel Programming 1 September 18th 03 03:14 AM
Copy Data to Rows instead of Columns Donnie Stone Excel Programming 0 September 17th 03 11:10 PM
Copy Data to Rows instead of Columns Donnie Stone Excel Programming 1 September 16th 03 03:08 AM


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