+ Reply to Thread
Results 1 to 22 of 22

code to insert dash sign

  1. #1
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    code to insert dash sign

    Dear friends,
    In my file ‘contacts’ I want to insert dash sign in columns ‘q to AA’ if there is a word ‘company’ in column ‘f’.

    I want to execute this function at the time of sorting. That means when the ‘sort’ macro will run. I want to add the code for it in ‘sort’ macro instead of creating a new macro because I want to execute this function simultaneously after sorting.

    Please provide me a code for it in ‘sort’ macro.

    Thank you in anticipation.

    Mukesh
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Like so:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Thank you. It's working fine, excellent!
    Now I want a little modification in it. I have made some change in it but now it's not working. I want to do the same when the column 'f' contains the word 'Organization' and 'School'.
    It's not gibving error but not giving the output.
    In short if the column 'f' contains either the three of words then the dash sign should be enter in column 'q to aa'.

    Please find the error and solve my problem.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files
    Last edited by mukeshbaviskar; 06-21-2013 at 01:04 PM. Reason: Attach the attachment.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Dear JBeaucaire,
    Excellent! Now it's working fine as per my requirement.

    Thank you very much for quick response and solve my problem.

    Mukesh

  6. #6
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Now I observe that each time I didn't enter the words organization, company, school in my directory. But in this code the macro runs each time I open the file which I don't want because it takes time to complete the task.

    Can you please do the little modification in this code? Require modification is:
    When I enter the words organization, company, school in column 'f' then immediately the dash sign should be enter in column 'q to y'. So that the macro will run little faster. To do this we have to remove it from sort macro modul 1 and create a separate macro for it. I want to remove it from auto run at the time of sorting.

    Please do it positively.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Put this code into the Access Sheet module:
    Please Login or Register  to view this content.

    In your original code reduces down to:
    Please Login or Register  to view this content.


    I think that's enough for one thread.

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

  8. #8
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Thank you for your guidance. I inserted the code in my modul but it's not working. When I type the word organization, company, school in column 'f' then the dash sign should be enter in column range 'q to y' automatically. after typing the word in column 'f' nothing happen. Please compile it again to solve my problem.
    Mukesh
    Attached Files Attached Files

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Quote Originally Posted by mukeshbaviskar View Post
    Thank you for your guidance. I inserted the code in my modul but it's not working.

    That's not where I told you you put that macro.
    Quote Originally Posted by JBeaucaire
    Put this code into the Access Sheet module:
    Please Login or Register  to view this content.
    This is a self-activating macro, so it must go into the sheet itself where it is to run.

    http://screencast.com/t/oaT8355e2X

  10. #10
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Thank you. I made change as per your guidance but still it's not working. Please do change in the file and attach it to avoide my mistake again. In this file I may have made some mistake so that it's not working.

    Thank you.

    Mukesh
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    You inserted a new standard code module. Why? IN the post above I told you specifically to put it into the ACCESS sheet module. I included a picture pointing directly at the correct module to open.

    I apologize for not doing everything for you, following instructions is part of the learning process. You can do this.

    Your Sort macro is not working any longer, go back to your original version back before we started all this.

  12. #12
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Dear JBeaucaire,
    Sorry for trouble. Actually I insertedthe code in access modul but it was not working so I inserted it in standard modul and try it. Now I have inserted it in access modul and corrected the sort code. Now the sort macro is working fine but the dash sign is not automatically enter in the column q to y after enter the word 'company, organization, school etc. Please go through it and solve the problem. Being a visually impaired person I'm unable to see the picture. Please don't apologize because you are guiding me and I'm making mistakes. Really I appreciate your knowledge of vba and I learned a little from you.

    Thank you.

    Mukesh
    Attached Files Attached Files

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    I'll have to take your word since that workbook you uploaded still has the macro in a code module instead of the sheet module.

    I see the problem. Your first sheet had "Company" but you want to type "company", not exactly the same. So, if you want the macro to behave in a non-case-sensitive way, add this to the top of the sheet module:

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Dear JBeaucaire,
    Sorry for trouble. Actually I didn't understand 'code modul and sheet modul' so the error is occurring. I don't want to type case sensitive words instead I want the first letter capital. By mistake I have written it in small letters for trial.

    To avoide such silly mistakes and complete this work I humbly request you to do the necessary change in my file and send me the corrected file and close this thread today. You are taking extra efforts to solve my problem but lack of knowledge I'm not following your instructions and this thread is going long and long.

    Do solve it today. Thanking you in anticipation.

    Mukesh

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Right-click on the ACCESS sheet tab and select VIEW CODE. This will open that sheet module.

    Paste the macro I gave you in there. Also add that extra line of code I noted in post #13.

    I am not going to do this for you. No offense. But if you can't find and open the sheet module for yourself with the multiple instructions you've been given, you shouldn't be using VBA.

  16. #16
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Dear JBeaucaire,
    Excellent! After all you taught me to do it myself. Really, you are a great teacher. If you didn't ask me to do it myself then I would have not learned it. Now I understand the difference between standared and sheet modul.

    I'm attaching the file for your reference. Please go through it and see whether I have made any mistake again. I want the first letter capital so I didn't enter the extra lines you have send me in last mail.

    Looking forward to learn a lot of things from you in future. Thanking you once again for taking extra efforts to teach me and solve my problem.

    Mukesh
    Attached Files Attached Files

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Excellent, you've got the code in the correct module and it IS working. Now, if want it to work the same whether you type "company" or "Company" or "CoMpANy", follow the instruction in post #13 to add that one flag at the top of the module. Then you should be done.

  18. #18
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Good evening! I want a modification in our dash code. When we enter the word 'Company' and other the dash sign automatically enter from column 'q to y' but I want some modification here, When we delete the word from column 'f' then the dash sign should be deleted automatically because sometimes by mistake I enter the words 'Company' and other in column 'f' then the dash sign comes in column 'q to y' and in this case after deleting the word from column 'f' I have to delete the dash sign from column 'q to y' manually which is time taking labourious job. I don't want to delete the dash sign manually. I want to delete it automatically after deleting the word from column 'f'.

    After working on it the problem occurs day by day so I'm asking you again and again. I'm modifying the contacts file. Please solve my problem.

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

    Replace all the code in the sheet module with this:
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Good morning JBeaucaire,
    Excellent! it's working fine. Now I think to add background music to my contacts file. is it possible through vba? I want to make my contact file more dynamic so I'm modifying it day by day. If you have any suggestions to make it more dynamic and informative I appreciate your suggestions.

    I want to keep contact with you regularly as my best friend. I like to make friendship with such a brilliant personalities.

    (Moderator's edit - personal contact info removed as per forum rules)

    Thanking you in anticipation.

    Mukesh
    Attached Files Attached Files
    Last edited by JBeaucaire; 07-06-2013 at 10:47 PM. Reason: Removed personal information from public thread, as per forum rules.

  21. #21
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: code to insert dash sign

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

    New completely unrelated questions should go in a new thread.

    -----------------
    If you're looking for private consultation, you can reach me through my website, link below in my signature. I believe you can continue to get excellent free assistance, though, right here through the forum.

  22. #22
    Forum Contributor
    Join Date
    12-15-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    672

    Re: code to insert dash sign

    Hello JBeaucaire,
    Sorry for posting personal information on forum. My problem is solved. I will start a new thread for new question.
    Thank you.

    Mukesh

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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