LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ~Help~ converting Excel equation to vba function


Hello,

I dont know if this can be done...

Say this is my equation in a cell:

=PROPER(LEFT(A1,FIND(":",A1,4)-1))&IF(CountOccurrences(A1,",,")0,"
"&"("&CountOccurrences(A1,",,")+1&")",)

And say A1 is a text =gift:something free,, is good,, can be bad
because it may explode

The equation returns: 'Gift (3)'<in A1 and the number 3 refers to
items separated by ",,"



HOW DO I PUT THIS INTO VBA PROGRAMMING SO THAT I CAN JUST HIGHLIGHT ANY
CELLS AND APPLY THIS FORMULA THAT WILL GIVE THE RESULT? UM.... IS THIS
EVEN SIMPLE TO DO?

"Countoccurences" is a user-defined equation that returns the number of
times substring appears in str:

Function CountOccurrences(str, substring) As Long
Dim x As Variant
x = Split(str, substring)
CountOccurrences = UBound(x)

----

I thought this may be possible because I happened to look at this
highlight-'n-apply-trimcleaning-macro:

Sub trimclean()
Dim CTRg As Range
Dim oCell As Range
Dim Func As WorksheetFunction

Set Func = Application.WorksheetFunction

On Error Resume Next
Set CTRg = Selection.SpecialCells(xlCellTypeConstants, 2)
If Err Then MsgBox "No data to clean and Trim!": Exit Sub

For Each oCell In CTRg
oCell = Application.WorksheetFunction.Clean(Func.Trim(oCel l))
Next


End Sub

But I'm so confused with all the functions listed here; dont know how
to make my own function.

Please help!


--
Ambrosia
------------------------------------------------------------------------
Ambrosia's Profile: http://www.excelforum.com/member.php...o&userid=28146
View this thread: http://www.excelforum.com/showthread...hreadid=480664

 
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
How do I chart a function (equation) in excel; not a data series? fluwoebers Charts and Charting in Excel 7 November 16th 07 07:34 PM
Converting an Excel Model into a Function Ankur Excel Worksheet Functions 5 December 28th 06 08:58 AM
Equation behind the Function ai18ma Excel Worksheet Functions 13 June 23rd 06 08:08 PM
Converting Lotus function to Excel Rubix Excel Worksheet Functions 1 March 5th 06 09:56 AM
memory? Excel Equation Function / Cond. Formatting Dropout nastech Excel Discussion (Misc queries) 2 January 25th 06 04:29 AM


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