Page 4 of 4 FirstFirst ... 234
Results 31 to 33 of 33

Thread: Special concatenation

  1. #31
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,324
    Rep Power
    10
    Code Again, for last few Posts

    Code:
    Sub  EvalutingQuotes()  'Posts  from  #25      http://www.excelfox.com/forum/f2/special-concatenation-2042/index3.html
    '---o00o---`(_)`---o00o---
    Rem  1)  Basics
    Dim  v  As  Variant
    Let  v  =  "3"  '    Results  in  a  Variant  variable  containing  a  string  value  "3"
    Let  v  =  3  '        Results  in  a  Variant  variable  containing  a  Long  Number  3  (  actually  an  Integer  ?  )
     
    Range("I1").Value  =  Evaluate("=A1")  'Explicit  Version
    Range("I1").Value  =  Evaluate("="  &  Range("A1").Address  &  "")  'Explicit  Version
    Range("I1").Value  =  Evaluate(""  &  Range("A1").Address  &  "")  'Implicit  Default
     
    Range("I1").Value  =  Evaluate("              "  &  Range("A1").Address  &  "              ")  '
     
    Range("I1").Value  =  Evaluate(Range("A1").Address)  'Common  but  dangerous  variation
     
    Rem  2)  Detailed  code  anylysis
    Dim  strEval  As  String  'String  to  be  used  in  Evaluate
     
    10    strEval  =  "=A1"  &  "&"  &  "A1":  Debug.Print  strEval  'gives  =A1&A1
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Result  Gives  11  in  cell  I1
     
    20    'strEval  =  "=A1"  &  "&""  &  ";"  &  ""&"  &  "A1":  Debug.Print  strEval  'gives  syntax  error
    'Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'errors
     
    30    strEval  =  "=A1"  &  "&"";""&"  &  "A1":  Debug.Print  strEval  'gives  =A1&";"&A1
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Result  Gives  1;1
     
    40    strEval  =  "=A1"  &  "&"";""":  Debug.Print  strEval  'gives  =A1&";"
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Gives  1;
     
    50    strEval  =  "=A1"  &  "&"";"  &  """":  Debug.Print  strEval  'gives  =A1&";"
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Gives  1;
     
    60    strEval  =  "=A1"  &  "&"";"""""  &  """":  Debug.Print  strEval  'gives  =A1&";"  ""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'error
    70    strEval  =  "=A1"  &  "&"";"";"""  &  """":  Debug.Print  strEval  'gives=A1&";";""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'error
     
    80    strEval  =  "=A1"  &  "&"";"""""  &  """":  Debug.Print  strEval  'gives  =A1&";"""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Did  not  error    Gives  1;"    !!!!!!!!
     
    90    strEval  =  "=A1"  &  "&"";"""  &  """"  &  """":  Debug.Print  strEval  'gives  =A1&";"""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Did  not  error    Gives  1;"    !!!!!!!!
     
    Rem  3)  Quotes  in  VBA  ...........
    100  strEval  =  "=A1"  &  "&"";""""""":  Debug.Print  strEval  'gives  =A1&";"""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  'Did  not  error    Gives  1;"    !!!!!!!!
     
    110  strEval  =  "=A1"  &  "&""""""""":  Debug.Print  strEval  'gives  =A1&""""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  '    Gives  1"
     
    120  strEval  =  "=A1&""""""""":  Debug.Print  strEval  'gives  =A1&""""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  '    Gives  1"
     
    130  strEval  =  "="  &  """""""""":  Debug.Print  strEval  'gives  =""""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  '  Gives  "
     
    140  strEval  =  "=""""""""":  Debug.Print  strEval  'gives  =""""
    Range("I1").Value  =  Evaluate(""  &  strEval  &  "")  '    Gives  "
     
    150  strEval  =  """""""""":  Debug.Print  strEval  'gives  """"
    Range("I1").Value  =  Evaluate(""  &  """"""""""  &  "")  '    Gives  "
    Range("I1").Value  =  Evaluate("""""""""")  '    Gives  "
     
    End  Sub  'EvalutingQuotes()  ---o00o---`(_)`---o00o---

  2. #32
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    @Alan

    Your posts are increasingly unreadable.

    If you are interested in 'Evaluate' have a look at:

    VBA for smarties How to fill a Combobox / Listbox

  3. #33
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,324
    Rep Power
    10
    Quote Originally Posted by snb View Post
    @Alan
    Your posts are increasingly unreadable...If you are interested in 'Evaluate' have a look at:.....
    @snb

    . Danke für das Info and hinweisen!
    (. Ich probier nur meines beste zu beides verstehen Code die ich benutzen und gleich Mitteilung was ich ( denke ) ich verstehe. )

    . Thanks for the info and advice!
    (. I just try myself to understand Code I use and at the same time to share what I ( think ) I understand )

    Alan

Similar Threads

  1. Flexible Concatenation Function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 23
    Last Post: 05-11-2019, 08:22 PM
  2. copy special cells with values and formats
    By rodich in forum Excel Help
    Replies: 1
    Last Post: 10-25-2013, 03:55 PM
  3. To Paste special by value
    By ravichandavar in forum Excel Help
    Replies: 7
    Last Post: 08-13-2013, 12:23 PM
  4. FORMATTED Flexible Concatenation Function
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 1
    Last Post: 10-14-2012, 03:48 PM
  5. Remove Special Characters :
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 3
    Last Post: 03-06-2012, 09:41 PM

Posting Permissions

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