+ Reply to Thread
Results 1 to 2 of 2

Problem with removing certain parts of formula

Hybrid View

  1. #1
    Registered User
    Join Date
    02-11-2014
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Problem with removing certain parts of formula

    Hello All,

    I have a problem with text formulas in VBA. The goal of the formula is to remove some parts of formula and brackets when the certain condition is fulfilled. When the formula is related to the cell in the same sheet, all works excellent, but the problem appears when the reference is to another sheet. And how it goes:

    The formula starts with: =('Cost Drivers & Assumptions'!J60)/SEK

    After i.Formula = Left(i.Formula, Oko - 2) it look like that: =('Cost Drivers & Assumptions'!J60)
    After i.Formula = Right(i.Formula, Len(i.Formula) - 2) it is: 'Cost Drivers & Assumptions'!J60)
    After i.Formula = Left(i.Formula, Len(i.Formula) - 1) it is : 'Cost Drivers & Assumptions'!J60

    Oko = InStr(1, i.Formula, "SEK")

    Up to this point everything is ok and now there should only be added "=" sign at the beginning and everything would be fine but it isn't

    After i.Formula = "=" & Right(i.Formula, Len(i.Formula)) the "=" is not added and the result in cell is 'Cost Drivers & Assumptions'!J60

    Strangely when I add an apostrophe after "=" into code like that : i.Formula = "='" & Right(i.Formula, Len(i.Formula))

    It works fine but later on is got screwed after many calculations. Does anybody have an idea why "=" cannot be simply added at the beginning and what might lie behind it? I have no idea. your help is very appreciated.

    Best regards,
    Last edited by mastahdaer; 03-13-2014 at 05:03 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Problem with removing certain parts of formula

    Better store the data in a variable and check....


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 01-18-2013, 11:21 AM
  2. Scan parts OUT to Sheet1, parts IN to Sheet2 and list in Sheet3
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2012, 11:40 AM
  3. removing parts of a cell mostly text
    By arambo in forum Excel General
    Replies: 2
    Last Post: 07-13-2010, 10:18 AM
  4. Excel Problem in 3 parts. Importing .xml
    By Korjaaja in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2007, 05:51 PM
  5. [SOLVED] Macro for removing some parts of data, using LEFT/RIGHT functions
    By Sach in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2006, 03:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1