+ Reply to Thread
Results 1 to 14 of 14

wrong declaration of variable?

  1. #1
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    wrong declaration of variable?

    Dear Users,

    if I run the code below I get an alarm that the label is wrong and pointing to my "LagerplNEU" variable.
    And I don´t know what the problem could be....

    If I run with the lines which are now commented out it runs.. but my goal is to add to the value of that variable some signs like: copy LagerplNEU & "//" to .....

    can somebody help me what is the problem?

    Please Login or Register  to view this content.

    thank you indeed!

  2. #2
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    Re: wrong declaration of variable?

    if I declare it as variant it works but I can not add some text to it.. can you help me?

    the problem is in that line:

    Please Login or Register  to view this content.
    Last edited by peterschein; 07-09-2019 at 02:28 AM.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,192

    Re: wrong declaration of variable?

    Please be patient. Most people in the UK and Europe will not yet even be at work.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    Re: wrong declaration of variable?

    of course I am I just wanted to show that I do an effort finding it out but probably I used the prhase "can you help me" too often...

    actually that doesnt work either:


    Please Login or Register  to view this content.

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

    Re: wrong declaration of variable?

    my guess, just get rid of "Set" key word from the last line.
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    Re: wrong declaration of variable?

    Dear Jindon

    I tried what you mentioned but didnt work out...

    this is the whole code:
    Please Login or Register  to view this content.
    the problem is in the marked row...
    Last edited by peterschein; 07-09-2019 at 03:25 AM.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: wrong declaration of variable?

    A String doesn't have a Copy method, but I don't see why you can't just use:

    Please Login or Register  to view this content.
    to assign the string to the cell.
    Everyone who confuses correlation and causation ends up dead.

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

    Re: wrong declaration of variable?

    Try declare that variable as Range then....

  9. #9
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    Re: wrong declaration of variable?

    Unfortunately non of them worked. I have the file attached and some explanation. the code is in MODULE "hinzufügen".

    with the lines that are commented out it works I just need to add some string to it automatically what the user writes in AO20...
    Attached Files Attached Files

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

    Re: wrong declaration of variable?

    Quote Originally Posted by peterschein View Post
    Unfortunately non of them worked. I have the file attached and some explanation. the code is in MODULE "hinzufügen".
    Just made two changes as suggested earlier and it's working fine for me with your below code.

    Please Login or Register  to view this content.
    Changes:-

    Removed Set keyword from signS = "/ /"
    Defined LagerplNEU as range.


    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

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

    Re: wrong declaration of variable?

    "Set" key word should be used to set the reference to the OBJECT, and if you assign the value to the variable, "Let" key word and it can be omitted.
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    10-26-2018
    Location
    Vienna, Austria
    MS-Off Ver
    MS 365
    Posts
    157

    Re: wrong declaration of variable?

    Thank you jindon!

    strangly I tried with let as well. I must have made some other mistake....
    and dimming a combination of numbers and letters as range is new for me. I will have to read about that.

    but cool, thank you all of you!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,192

    Re: wrong declaration of variable?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

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

    Re: wrong declaration of variable?

    You are welcome and thanks for the rep.

    Yes, better study about variable types and your coding skill will get much better.

+ 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. [SOLVED] Variable declaration
    By captbluefin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2017, 01:37 PM
  2. [SOLVED] Excel VBA creating Range from set cell, variable declaration wrong
    By Simone Fick in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-12-2017, 05:32 PM
  3. VBA variable declaration and assignment help
    By anthony777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2017, 04:28 PM
  4. [SOLVED] Variable Declaration issue
    By NewToCode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2012, 01:57 PM
  5. Range Declaration using Variable
    By wfire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2009, 11:43 AM
  6. Adding a variable into a range declaration
    By Malvaro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2008, 03:53 PM
  7. A disturbing behaviour of DIM (for variable declaration)
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2005, 01:20 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