+ Reply to Thread
Results 1 to 7 of 7

search and replace number

  1. #1
    Registered User
    Join Date
    12-20-2015
    Location
    Ekeren
    MS-Off Ver
    Office 2010
    Posts
    17

    search and replace number

    Hi everyone,

    A friend of mine asked me if it's possible to make a timetable.
    I started with a basic table, where you can fill in the hours per day, per employee with a validation list.
    Easy but it works.
    However he asked me something else :

    Is it possible to don't use a validation list, but use numbers/codes which stands for a certain time period?
    for example : every time he fills in "1" it stands for 08:00-17:00 ; "2" is 08:00-15:30,....
    After a macro has run, the numbers and codes will change into the right hours.

    I hope the attachments makes it clear. I've used both methods

    Should I work with VLookup?

    Thanks for your advice
    Star
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: search and replace number

    I used the "Worksheet_Change" sheet event.
    Attempted solution in the attachment. Maybe that was it.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Best Regards,
    Maras.

  3. #3
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: search and replace number

    Formulae wouldn't work because you need the cell to change itself, which Excel can't do (formulae have to refer to other cells and post the result where the formula is).

    Attached is in Sheet code, and runs every time you change any of the cells in C9 to J10 (in green). To extend it just change the SHIFTS range to whatever cells you want to include.

    Please Login or Register  to view this content.

    Enter any of the "TIme" numbers from Col A of the Data CGE sheet into any Green cell, and it will convert to the matching times automatically,
    Clear the cell and the Macro stops.

    Ochimus
    Attached Files Attached Files
    Last edited by Ochimus; 12-02-2020 at 08:06 PM.

  4. #4
    Registered User
    Join Date
    12-20-2015
    Location
    Ekeren
    MS-Off Ver
    Office 2010
    Posts
    17

    Re: search and replace number

    Hey Maras, Ochimus,

    Thank you for your solutions. I've tried both and the worked fine. At the moment I'm using the code of Ochimus, but I have an issue.
    The sh.Range doesn't work. Whatever I fill in, the code keeps working over all cells of the sheet. And it needs only working over a range.
    Star

  5. #5
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: search and replace number

    Starchaser,

    Can you please replace the code with this version, which sets SHIFTS in the sample as "C9:J10", not "C9:O19", and includes an Error trap that for some reason I omitted!

    Please Login or Register  to view this content.
    As in the original message, I assume you will change the range to the full range of those you want this to work on?

    Hope this helps

    Ochimus

  6. #6
    Registered User
    Join Date
    12-20-2015
    Location
    Ekeren
    MS-Off Ver
    Office 2010
    Posts
    17

    Re: search and replace number

    Hey Ochimus,

    It still doesn't work. Whatever range I use, you can fill in the codes on every cell of the entire worksheet.
    Very strange...

  7. #7
    Registered User
    Join Date
    12-20-2015
    Location
    Ekeren
    MS-Off Ver
    Office 2010
    Posts
    17

    Re: search and replace number

    Hi everyone,

    I still can't figure out why the range doesn't work.
    Anybody an idea?
    thanks for the help
    grtz

+ 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] how to make search and replace as text and not a number
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2016, 02:24 PM
  2. Current month - number to text with three letters, search & replace
    By gliori in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-25-2015, 08:14 AM
  3. Replies: 1
    Last Post: 02-20-2014, 12:24 PM
  4. search within text file and replace strings with variable number of characters
    By ingolf_ingolfsen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2012, 03:54 AM
  5. [SOLVED] search for text, then search for previous text, replace 1st text including number from 2nd
    By kldailey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2012, 05:23 PM
  6. [SOLVED] Modify left-search formula to replace letter with number
    By Mikey7346 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-27-2012, 05:30 AM
  7. Search for and replace last X number of characters
    By garden_gnome in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2012, 05:15 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