+ Reply to Thread
Results 1 to 17 of 17

More efficient way to Substitute more than 200 cells ?

  1. #1
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    More efficient way to Substitute more than 200 cells ?

    I'm preparing a macro where I have to subsitute more than 200 different text strings

    The code is the basic:

    Please Login or Register  to view this content.
    But repeating this code for more than 200 words/strings doesn't look a good idea to me

    Is there a more "efficient" way to do this ? "store" a kind of table separately ?

    thanks
    Nicola
    Last edited by jeffreybrown; 02-19-2018 at 11:50 AM. Reason: Please use code tags!

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: More efficient way to Substitute more than 200 cells ?

    Ciao Nicola,

    Does this thread give you some ideas?
    HTH
    Regards, Jeff

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    Hi & welcome to the board
    How about
    Please Login or Register  to view this content.
    This is based on having a list of old values & a list of new values, change sheet names ranges to suit.

  4. #4
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    thanks to both, I'll dig in !

  5. #5
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    @Fluff13

    at line:

    Please Login or Register  to view this content.
    instead of "Sheet3", can I put an external link, something like:

    Please Login or Register  to view this content.
    if so, how's the correct syntax ?

    thanks
    Last edited by jeffreybrown; 02-20-2018 at 08:35 AM. Reason: Please use code tags!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    You need to open the file first, which can be done like this
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    I still have to test this,

    quick question: this method works on multiple cells on the same column right ? not on a single cell ?

    thanks

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    Yes, it works on the entire column.

  9. #9
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    thanks !

    Nicola

  10. #10
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    forgive me ...
    I'm worst than expected at this, just fighting with the syntax and I can't control the result / output properly

    I have FOGLIO.XLSX,

    in column D, starting from row 2, there are the values that has to be replaced

    D
    OLDVAL1
    OLDVAL2
    OLDVAL4
    OLDAVL1
    OLDVAL1
    OLDVAL5
    ....

    these values in D has to be replaced with the values from column B of the file c:\documenti\table.xlsx

    A B
    OLDVAL1 NEWVAL1
    OLDVAL2 NEWVAL2
    OLDVAL3 NEWVAL3
    .... ....


    thanks

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    Ok, just a few questions.
    1) Which workbook contains the macro, as both the files you've mentioned are .xlsx files, is it a personal macro workbook?
    2) What is the name of the sheet in table.xlsx containing the old & new values?
    3) What is the name of the sheet in Foglio.xlsx that contains the values to be changed.

  12. #12
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    The macro will be stored in PROCEDURE.XLSX, the file that contains all the Macros (instead of the usual personal.xlsb),
    let's call it 'List'
    let's call it 'foglio1'

    cheers

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    Ok, try this
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    it works

    I had to change A2 and B2 to A1 and B1, because the list starts from row 1 in table.xls

    MANY thanks
    Nicola

  15. #15
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: More efficient way to Substitute more than 200 cells ?

    Glad to help & thanks for the feedback

  16. #16
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    A little help needed...

    This Macro is now within "PROCEDURE_SR.xlsm", the "Table" has to be moved on the second sheet of this file, located in C:\Documenti

    but no matter how many checks I do on the file name, the macro stops on the line Set Wbk2 = Workbooks("C:\Documenti\PROCEDURE_SR.xlsm"), like if the filename is wrong or the file's missing



    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    02-19-2018
    Location
    Rome
    MS-Off Ver
    2010
    Posts
    10

    Re: More efficient way to Substitute more than 200 cells ?

    I had to remove "C:\Documenti\"



    but now it 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] Most efficient way to paste 100s of cells at once..
    By moonbreakker in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 05-19-2017, 09:01 AM
  2. [SOLVED] efficient vba code for copying cells
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2015, 07:09 PM
  3. Replies: 4
    Last Post: 10-28-2014, 11:04 PM
  4. More efficient way to loop through cells and assign values
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 40
    Last Post: 08-29-2013, 05:54 AM
  5. more efficient way of getting range of non-empty cells?
    By adds007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2010, 01:30 AM
  6. Efficient formulas (naming cells)
    By Vlad999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2007, 05:47 PM
  7. Is this an efficient use of named cells?
    By Vindaloo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2006, 11:30 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