Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() sFilename = ActiveWorkbook.Name or sFilename = ThisWorkbook.Name -- HTH Bob Phillips "RAP" wrote in message ... Hello, Bob I guess I'm "in-between" using pure worksheet function and pure VB, as I have not assigned the filename to a variable. Currently, I'm using "ActiveCell = ActiveWorkbook.Name". Variable would be better. Care to give me the "assign filename to variable" lesson? I'm ready... Thanks, Randy "Bob Phillips" wrote: Hi Randy, I will make an assumption that the filename will be assigned to a variable. Post back if not so. Dim sFilename As String, cLen As Long Dim sFilenameSans As String, cLenSans As Long sFilename = "myTest01.xls" cLen = Len(sFilename) cLenSans = cLen - 4 sFilenameSans = Left(sFilename, cLenSans) Those are step by step, although it could all be amalgamated Dim sFilename As String, cLen As Long Dim sFilenameSans As String, cLenSans As Long sFilename = "myTest01.xls" sFilenameSans = Left(sFilename, Len(sFilename) - 4) -- HTH Bob Phillips "RAP" wrote in message ... Hello, Bob As I re-read my entry, I can see how unclear it really was. My apologies. What I am trying to do is: put into VB script what I can do using worksheet functions in cells. This is my method of learning VB on an "as needed" basis. School is scheduled, but I need to "make do" until then. Many thanks for all input from members of this discussion group. My "on-line" time is limited where I am currently located, so I can only search & read this discussion group for a short time. What I am currently doing is: 1. Using VB to fetch the filename and placing it in cell B1., 2. Counting the filename characters using " LEN(B1) placed in D1. , (12 in this case) 3. Cell D2 is assigned the number 4, which equals the number of characters that make up the ".xls" portion of the filename I want to remove., 4. In cell D3 I have the formula: "=D1-D2" (12-4=8)., 5. Cell D2 has the formula: "=LEFT(B1,(D1-D2))", which returns the filename, minus the file extension. I am linking cell D2 to a chart title. I'm building a template file that is going to be duplicated approximately 30 times, and I am attempting to use good programming techniques to minimize "hard-coding" various aspects of the template. Re-stated, now with more info, my question is how to achieve the same results using VB only. I believe I have the solution worked out, except that I am having difficulty using variables in the VB equivalent to the formula used in Step 4. Hope this helps. Thanks for the input. The link you sent will be read thoroughly. Randy "Bob Phillips" wrote: Maybe not be understanding, but take a look at http://www.xldynamic.com/source/xld.xlFAQ0002.html -- HTH Bob Phillips "RAP" wrote in message ... Using LEFT formula and LEN result, I need to apply the result (8) in a new LEFT statement and display the results in a cell. I am getting the filename, removing the file extension, and want to apply the formula result (which = # characters to display from original filename), and display in a new cell. How can I apply my variables in a new LEFT statement? Thanks, Randy |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert formula result to string | Excel Discussion (Misc queries) | |||
how to apply bold within string text | Excel Worksheet Functions | |||
equation as text string and its numeric result | Excel Discussion (Misc queries) | |||
Is it possible to apply IF's to "operator" result.. | Excel Discussion (Misc queries) | |||
Can I apply Cond. Formatting to a Formula result? | Excel Worksheet Functions |