+ Reply to Thread
Results 1 to 14 of 14

store cells value as a string variable

  1. #1
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    store cells value as a string variable

    hey guys,

    i guess my Problem should be very easy to solve, but i cant manage to do so ...

    i have several words in sheet2.one word per line. every line in sheet1 should be checked and deleted if the line (colum 3 and 4) contains any of the words in sheet2. i decided to go with two for-loops,
    my Problem is a error in line 7 and 9 (indicated by arrows). it seems to me that ...Cells(...).Value is not allowed for strings. i already tried .Text, checked several VBA Forums but could not find a solution. Anyone here to help me out? i would be very pleased.

    Please Login or Register  to view this content.
    Tanks in advance!
    Last edited by sebdor; 08-02-2014 at 01:25 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: store cells value as a string variable

    Hi, sebdor,

    you would need to wrap your procedure with code-tags according to Forum Rule #3 and your problem should get solved in no big time thereafter.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    Re: store cells value as a string variable

    thanks. done.
    Last edited by sebdor; 08-02-2014 at 01:25 PM.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    Use ".Value" to get the value of the cell what ever the value
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: store cells value as a string variable

    Hi, sebdor,

    using one loop for the shorter list, WorksheetFunction.CountIf and Application.Match or Find could speed up the time for the macro.

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    Re: store cells value as a string variable

    i already use ".Value", does not work, sorry.

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    What means "does not work", what is the error?
    Can you send a short sample of your file.
    BTW see the use of EVALUATE with COUNTIF

  8. #8
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    Re: store cells value as a string variable

    it is error 438 "object does not Support property or method"
    sorry, i somehow deleted it. should have been in my initial post.
    seems very common in Forums, but i couldnt find a solution that works for me. a lot of People use "range" instead of "cells" but that does not work for me as i have cells indicated by the for-Loops.

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    Can you show how the data is, is it really string?

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    Try
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    Re: store cells value as a string variable

    here You go.
    a litte Background: a have a huge list of Train Connections. i want to delete all Connections (lines) that contain a Train Station outside of Germany (depature: col 3, Arrival: col 4). sheet 2 is my list of Train Station outside of Germany.

    https://onedrive.live.com/redir?resi...F8353B%2122094. capute of sheet 1 and 2. the three colums are definityl formatted as string.

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    Please send an excel file or try
    Please Login or Register  to view this content.
    Last edited by PCI; 08-02-2014 at 02:39 PM.

  13. #13
    Registered User
    Join Date
    08-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    6

    Re: store cells value as a string variable

    the macro runs ... thank You!
    i can understand the way You solved the Problem. but im wondering why the line i1 = ActiveWorkbook... does not throw out the same error i had. it is basically the same ... ?
    any idea on that? it is not really important since it works now

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: store cells value as a string variable

    As far as I have understood
    Please Login or Register  to view this content.
    does not work
    Please Login or Register  to view this content.
    works
    Please Login or Register  to view this content.
    works

+ 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] Store RGB(x, y, z) As Variable
    By ntitled in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2014, 01:05 PM
  2. Replies: 8
    Last Post: 11-11-2012, 07:22 PM
  3. Transferring a dynamically named string variable to another string variable.
    By Concorde Rules in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2012, 04:08 AM
  4. [SOLVED] Store variable in worksheet and use that variable in VBA code
    By ExcelGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 08:20 AM
  5. How to store Cells(1,1) into variable
    By KeyCode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2010, 05: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