hi,
I am looking to clear the contents of E120:K152 if the word STOP appears in cell G1
I need to apply this to 60 seperate sheets
Thanks for any help
Paul
hi,
I am looking to clear the contents of E120:K152 if the word STOP appears in cell G1
I need to apply this to 60 seperate sheets
Thanks for any help
Paul
Something like this...All 60 sheets in same workbook?
Please Login or Register to view this content.
Good Luck
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the star to left of post [Add Reputation]
Also....add a comment if you like!!!!
And remember...Mark Thread as Solved.
Excel Forum Rocks!!!
Try:
Please Login or Register to view this content.
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
thank you for your response ... yes all 60 in the same workbook ... but there are other sheets in the workbook that I would not want this to apply to, so does that mean that I have to place this code in each sheet ?
cheers
Paul
No, the code, in both examples, loops through every sheet in the workbook. You would need to specifically include the worksheets you want tested or exclude those that you don't. Assuming there are less that you want to exclude, you'd need to create a list of them in the code, or on a worksheet.
That said, if you don't have STOP in cell G51 on the sheets, then the macros don't change anything.
No the sheets need to be excluded like this...
Please Login or Register to view this content.
Please Login or Register to view this content.
thanks to you both for your help, much appreciated
Regards
Paul
Glad I could contribute...Tx for rep +
You're welcome. Thanks for the rep.
I put the code as follows into a Module ..
but it has caused a problem with other code I have in another module as follows ..Please Login or Register to view this content.
Please Login or Register to view this content.
Have I put it in the wrong place or is the clash inevitable
Thanks again ..
Last edited by sherman51; 01-17-2018 at 10:57 AM. Reason: has caused a problem with other code
Your post does not comply with rule #3.
3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing.
So, do the following pls:
Edit your post, highlight your code and click the [#] button at the top of the post window.
Other code in same module....Could be because you have not declared variables...has caused a problem with other code
Last edited by sintek; 01-17-2018 at 10:37 AM.
....deleted....
i tried that, but seems to have made no diference to the post, sorry I don't know what else to do ..
Cheers
Paul
Tried what...I asked that you edit Post 11
So, do the following pls:
Go to Post 11 and Edit your post by highlighting your code and click the [#] button at the top of the post window.
The only problem I can see is you haven't declared DataSht, DestSht or Cntr.
Add this at the top of the module just below Option Explicit.
Please Login or Register to view this content.
If posting code please use code tags, see here.
thats what i did .. shall i try to re-post ?
As per post 12...Do what Norie suggests in Post 16 and will solve...Could be because you have not declared variables...
got it now thanks .. both start and end codes were going in together, my apologies ..
will try that, thanks again guys ..
I added the lines posted by Norie (post 16) but I still had the clash with other vba problem, also the "clear cell range " vba did not work .
I then tried the code posted by TMS (post3), this does not cause a problem with other vba but does not clear the cell range either ..
Any further advice would be much appreciated ..
Paul
Paul
Any chance you could upload a sample workbook?
Click on GO ADVANCED, scroll down and click Manage Attachments.
i'd be happy to copy all the codes if that would help.. not sure that posting the workbook would help as there is a procedure to get teh links up and running from the source (which you would need to be subscribed to) in order to see if there's a clash ..
would that help ?
Thanks
Paul
Codes won't help...Just out of curiosity...Where did you put norie's declare code...
Edit...
You are still to tell us what problem it causes...error Message ?but it has caused a problem with other code
i'd be happy to copy all the codes if that would help.. not sure that posting the workbook would help as there is a procedure to get teh links up and running from the source (which you would need to be subscribed to) in order to see if there's a clash ..
would that help ?
Thanks
Paul
changed "Stop" to In-Play and excluded the sheets that didn't need the code ...Please Login or Register to view this content.
There's your problem...
Norie's declare statements...
Should go below...Your other Module...the one causing the problems...
Please Login or Register to view this content.
Last edited by sintek; 01-17-2018 at 02:22 PM.
"In-Play" turned out to be the text and not Stop .. or can you see something other ? ..
Sintek
The declarations should be at the top of the module, not in a sub, because they are used in two subs, TimePaste and Setup - see post #11
Not ideal I know but the code would need to be rewritten to avoid that.
@ Norie
Sorry did not notice that...Still a problem though...See post #26
Wrong module perhaps...
Public Declare?
sintek
To be honest I'm not actually sure what the problem is, the declarations don't actually have anything to do with the sub named Clear.
I think it might help to see all the code, the error message(s) and/or a sample workbook.
Yeah true Norie
OP is still to tell us what the errors are... So come on now Sherman51...get with the program...
thanks for your help so far guys, I now seem to have another problem, when I open the macros to view/edit, I can't do anything with them, just keep getting a sound/ding .. I'll have to get back to a working copy and start again ..
I actually have to go shortly and so will pick it up tomorrow if thats ok ....
Thanks again
Paul
This is all the vba code in the workbook ..
Please Login or Register to view this content.
Please Login or Register to view this content.
hope this helps ...Please Login or Register to view this content.
. and there are a couple of macros that I have recorded for copying and sorting ..
when teh vba hangs, i hit de-bug and the purple text above is what's highlited ..
Paul
Last edited by sherman51; 01-17-2018 at 03:29 PM.
You have two Workbook_Open routines. That can't be right.
When it hangs and you Debug it, what values do the public variables have?
Not sure if the value of having a separate Setup routine.
sorry, not sure what the public variables are .. teh workbook runs fine, it was only when I addes todays code that there was a problem, and when i hit de-bug it highlited the code I made purple in teh above post (34) ..
These are the public variables
We're all guessing here. Please post the workbook so we can see it in context.Please Login or Register to view this content.
Any chance you could upload a sample workbook?
Click on GO ADVANCED, scroll down and click Manage Attachments.
Hi guys, apologies for the delay, ... life's distractions ..
I have found that this code works if I manually type into cell G1, but it dosent work when cell G1 changes from blank to having text in it ...
Is there a difference in a cell being "updated from an outside source" and manualy typing in a cell? and can I get around it ?
thanks
Paul
Please Login or Register to view this content.
Well, two things. 1) you're using a Selection Change Event handler so you only have to select a/any cell and it will fire; you don't have to type anything. And 2) a Change Event handler only fires if you manually change a cell or you use code to change the value of a cell; it doesn't fire when the value of a formula changes.
ok, thank you for your reply ...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks