+ Reply to Thread
Results 1 to 16 of 16

VBA coding only working in the first sheet. It is not working in all the sheets

  1. #1
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    VBA coding only working in the first sheet. It is not working in all the sheets

    Dear Sirs,

    I am just started macror/vba coding.

    I have created a coding for displaying number in Indian currency in indian format(comma separator) in excel 2007. Though it is working in the first sheet It is not working in all the sheets. Please guide me on this.

    I would like to learn how to protect the coding. If am sending this file to others other users should not view the coding.

    code i have used as follows

    Please Login or Register  to view this content.
    Thanks & Regards
    N.Srinivasan
    Last edited by JBeaucaire; 09-14-2012 at 11:59 PM. Reason: Added code tags, as per forum rules. Don't forget!

  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: VBA coding only working in the first sheet. It is not working in all the sheets

    That macro would have to be inserted specifically into the sheet module of each sheet where you want it to work. If you have 3 sheets, then you will right-click on each sheet tab, VIEW CODE, and paste in the code. So that's 3 modules, 3 copies of that same macro.


    Here's a version you can put in the ThisWorkbook module instead, this one macro would then watch ALL sheets and act accordingly on all sheets:
    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
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Thanks a lot .

    I am able to work on your ist solution.(copying and pasting in the every sheet)
    However second option workbook option does not work Probably i am doing wrong is it possible to post coded excel.
    I require to know how to protect the coding with password

  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: VBA coding only working in the first sheet. It is not working in all the sheets

    Put the code given in post #2 in the ThisWorkbook module.

    http://screencast.com/t/YliZx6oqUOEj

  5. #5
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Thanks a lot
    I am unable to get the relevant output.Though I have copied the code as given post2.
    Hence I have attached the fie for your investigation from my email id.
    Requesting you to do the needful.
    Thanks

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

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    I don't see an attachment. Try again, and make sure the macro I gave you is already installed so I can see what you tried. Thanks.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

  7. #7
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    NS1509.xlsm
    Dear sir file is attached.

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

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    I opened your file and started clicking on cells in various sheets, every cell I clicked on reformatted itself.

  9. #9
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Thank you very much,
    How to make this happen after pressing enter key or tab
    ie while entering the number it should get formatted by itself
    Last edited by srinivasan1965; 09-15-2012 at 11:50 PM.

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

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Change this:
    Please Login or Register  to view this content.
    To this:
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    I am unable to erase or insert or delete row. It throws error no.13
    Please help
    file is attached(ns1509protected1)
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    The code want to change the values and therefor you get an error.

    if you put an ' before above line in the code, you will be able to delete, insert, erase, rows.

    After you've done that you have to delete the ' for the code.

    With other words, you have to rewrite the code so you will be able to do delete, insert and erase.

    I can't help you with that, maybe someone else can make it for you.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  13. #13
    Forum Contributor
    Join Date
    09-14-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    239

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Thanks a lot.
    As a beginner I am not able to understand this as a whole.
    is it possible for you send a note pad of coding for this problem
    Thanks sorry to trouble u

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

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    Add this line at the top:
    Please Login or Register  to view this content.

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

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    thanks your sirs. it is working fine

  16. #16
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA coding only working in the first sheet. It is not working in all the sheets

    @ srinivasan1965

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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