Closed Thread
Results 1 to 5 of 5

Cascade String concatenation problem

  1. #1
    Registered User
    Join Date
    01-03-2020
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    2

    Cascade String concatenation problem

    Hi everyone, I am pretty new to vba but I have been coding for a long time in c/c++. What I want to do is :
    When I write on a selected cell for example INTC I want the cell right next to it to display sometihng like FIBBONACCI('INTC') <= 50

    So what I did is : use Worksheet with change and this is the code :

    Private Sub Worksheet_Change(ByVal Target As Range)


    Dim SymbolName As String
    SymbolName = Target.Value
    ActiveCell.Offset(-1, 1) = "FIBBONACCI(" & SymbolName & " ) <= 50"


    End Sub

    But the result keeps cascadiing :


    FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACC I(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONA CCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBO NACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIB BONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(F IBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI (FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(FIBBONACCI(intc ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50 ) <= 50

    What is wrong in my code? Thank you very much

  2. #2
    Registered User
    Join Date
    01-03-2020
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    2

    Re: Cascade String concatenation problem

    This is the unwanted result what I want is only FIBBONACCI('INTC') <= 50 Thanks againAttachment 656336

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Cascade String concatenation problem

    Why not just use a formula?

    =if(A1="INTC","FIBBONACCI('"&A1&"') <= 50","")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Cascade String concatenation problem

    1)
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html


    2) You need to disable event when you change the cell otherwise it will go into infinite loop.
    Please Login or Register  to view this content.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Cascade String concatenation problem

    This post has been reposted in the CS forum, so I am closing this now

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Conditional String Concatenation
    By Solentos in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-20-2019, 12:33 AM
  2. Help with string concatenation logic
    By Nahkranoth in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-16-2013, 06:49 AM
  3. String concatenation of values
    By Chuvawow.com in forum Excel General
    Replies: 9
    Last Post: 03-08-2010, 07:29 AM
  4. string concatenation
    By jaredhawco in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-02-2008, 05:02 PM
  5. string concatenation
    By deepak.kec in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-21-2008, 04:34 AM
  6. string concatenation
    By fanfan in forum Excel General
    Replies: 2
    Last Post: 09-14-2007, 03:09 PM
  7. [SOLVED] String concatenation
    By shishi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2005, 10:05 PM

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