• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro wont work on other sheets

Sometimes I get brain lock up I think LOL

I have a book with 54 sheets. I have a Macro that works fine on sheet 1. I have gone to my code and double clicked to the left where I want my code to go on a new sheet. I copied it and pasted it to a new sheet and it wont run. What am I doing wrong?
 
Can you please post the macro here ?
Which Module was the code in originally ?
 
Sorry Hui, thought I did.

The actual nook is too large for me to upload so I hope what I find out on this one I can carry over to the master book

Go to the tab E-O1 TEST and click on one of the cells 1 CDEF or 1 JKLM etc..., you will see the 4 digits in row move up to the next row. If you go to Numbers E-O1 and do the same nothing happens. Why?
 

Attachments

  • Copy of MASTER Updates short sheets_EB_V2.xlsm
    70 KB · Views: 3
Jack

If I go into VBA
Then select the Sheet3 (NUMBERS E-O1 test) worksheet module
I copy the Worksheet_SelectionChange() event
and paste it in the Sheet2 (NUMBERS E-O1) worksheet module

the code works as expected in the NUMBERS E-O1 worksheet

What is your specific issue?
 
I have apprx 60 sheets in a book with this macro copied to all of them and I can not get them to run. I am not doing something correctly. I would like a step by step what to do
 
Hui,

Here is a pic of what I am looking at. I am familiar with writing formulas but Macros are very new to me. Can you tell me step by step what to do. Is the module I click on one of these files in the picture?
 

Attachments

  • VBA Project.jpg
    VBA Project.jpg
    75 KB · Views: 4
Instead of using a Worksheet_SelectionChange() event
If you copy the entire code into a Workbook_SheetBeforeDoubleClick() event
It will then work on All worksheets
You have to Double Click instead of simply selecting the cells

See attached file:
 

Attachments

  • MASTER Updates short sheets_EB_V2_Hui.xlsm
    68 KB · Views: 2
Instead of using a Worksheet_SelectionChange() event
If you copy the entire code into a Workbook_SheetBeforeDoubleClick() event
It will then work on All worksheets
You have to Double Click instead of simply selecting the cells

See attached file:
HUI,

When I open this file nothing happens? They do not work?
 
no sir, I was clinking once as that's what I did on sheet E-O1. Thank you , now, for all my other sheets, can you tell me step by step how to get them to run. I have them all loaded and the Macro copied tot he worksheet. Was I suppose to copy them to a "module" Thank you for your help!!!
 
The macro in the workbook module I sent you above has to go in the workbook module of your workbook
That's it
Save as a Xlsm file
 
Thanks Hui, but I have placed the code in a module and my other sheets do not work. I am not familiar enough with macro placement and I am sure I am placing it incorrectly. I go to ALT 11 and double click on the work module in the far left, then I paste the code in there, save a copy and it does not work on a new sheet

This is my MASTER book that I am trying to get all the sheets working in including the tabs under 1CDEF (this updates all the counters on each specific sheet at one time)

http://www.mediafire.com/view/qhaudqwd7qbzz2o/Copy_of_MASTER_Lotto_Texas.xlsm
 
Excel models have 3 levels or types of code locations
Workbook Modules
Worksheet Modules and
Code Modules

See picture below:
Capture.jpg

The location for Event specific code must be in the correct location, in this case the Workbook module

Code Events are specific to the location of the object that apply to, in this case the Workbook module
 
so I want to delete all the macros I have pasted in the wrong modules and paste them in the one labeled Thisworkbook module(s) and the individual worksheet?
 
No

Your existing macro works in the worksheet that it is located in
You could copy that module to every worksheet module but that would be sloppy

The code I gave you in the file above is in the Workbook module
It works on every worksheet, but you have to double click on the cells C1:F1 in row 1 etc, not single click
 
I have them working ....thanks, I deleted all the macros from all the sheets and installed it in ONLY THISWORKSHEET and its working great except my conditional formatting is not there
 
Conditional formatting is a property of the worksheet and has nothing to do with the Macro

You will need to reinstate it to the cells as appropriate
 
Back
Top