I have two codes running that are both worksheet_change
What do I have to do to make the name acceptable and run?
I have two codes running that are both worksheet_change
What do I have to do to make the name acceptable and run?
You can't have two only one. You can combine them.
Last edited by JOHN H. DAVIS; 08-14-2015 at 10:40 AM.
Have you tried Debug > Compile VBAProject ?
If it still doesn't detect the error, then look for two identically named Public variables in two different modules.
I had this yesterday - causes all sorts of weird behaviour like not being able to step into code from a Worksheet function.
Usually 'Debug > Compile VBAProject' picks up this sort of thing, but yesterday it didn't.
How would I combine these two. Essentially they do the same thing, I'm just very new at VB.
The first one likely isn't setup properly.![]()
Please Login or Register to view this content.
B14 down to B50 are the dropdown cells and I need the adjacent C,D, and E dependent lists to clear (again 14 to 50)
The second code works great. J6 is my dropdown list and the dependent lists H3, L3 and L6 clear when info is changed.
thanks
I've changed the other code and both work fine on their own.
I can't figure out how to combine them however.
![]()
Please Login or Register to view this content.
Something like this:
![]()
Please Login or Register to view this content.
That is most excellent. Thank you.
I have 4 identical tabs, order, order(2), order(3), order (4)
How do I make the code run for all of them?
thanks
Try this:
(untested, BTW)![]()
Please Login or Register to view this content.
Either copy the code to each worskheet module or use the workbook SheetChange event.
![]()
Please Login or Register to view this content.
If posting code please use code tags, see here.
It doesn't seem to work, perhaps they should be the sheet #'s instead of 'names'?
Did you try the code I posted?
It goes in the ThisWorkbook module.
Sorry, slow connection today. Storm went through.
How do I get to ThisWorkbook module?
When I select the sheet under microsoftexcelobjects in the window the code is still there for my original sheet.
Double click ThisWorkbook in the Project Explorer.
Yeah, me too. My code is supposed to go in the Workbook_SheetChange event also. Tsk, writing on the fly.Sorry, slow connection today
Ah, that helps.
Unfortunately not working though.
edit:
Will try that cyiangou.
unfortunately my firs (order) tab still works but not on the others
Any chance you could upload a sample workbook?
Click on GO ADVANCED and use the paperclip icon to open the upload window.
I will. It will take a few minutes to update my dropbox file with my currently ludicrously slow speed.
I will try to do this at a later time. My upload speed is very slow.
Thanks for the help so far. I'll process it further. Probably something I'm doing wrong.
In my code, please check the line
and make sure the exact names of your tabs are in each field, eg. order(3) has no space, but order (4) does? I copied these directly from your post.![]()
Please Login or Register to view this content.
Still working on the upload of my file. Speeds as low as 0.3 kb/s
I was trying the different ideas out but now even my separate codes are not working anymore. Not sure what I did.
https://www.dropbox.com/s/26nenkmsce...ftge.xlsm?dl=0
My file.
I inputted this code into each of the four sheets. It's the closest I got to it working (not on the dropbox one)
The first sheet "order" works totally fine. But with the other three, only the first half runs.![]()
Please Login or Register to view this content.
Ok, I've now tested this code in your file. Comment out your Worksheet_Change subs in the 4 sheets. Add this to your ThisWorkbook module:
I made a few changes, verify that my assumptions are correct:![]()
Please Login or Register to view this content.
- I assumed that in the range reference 'Range("H3:J3,L3:N3,L6:O3")', the L6:O3 part was a mistake and was meant to read L3:O3 ?
- I also assumed that in the 2nd IF block, that you intend that when an entry is made in column B, that you want the 3 columns to the right to be cleared, but ONLY FOR THAT ROW, and not ALL the detail rows.
Thanks very much. It seems to be working great now. Good catch on the L6:O3 it was actually supposed to be L6:O6.
Yes you are correct on just the 3 columns clearing and not the entire row.
This has been a hurdle for m.e It's great to be moving on to new ones.
cyiangou
Just curious, why are you using Target.Worksheet.Name?
If you want to get the name of the sheet the change has been made on use Sh.Name.
@Norie
I always felt that the sh object was superfluous. I guess it's just me proving once again that it's unnecessary.
cyiangou
Kind of confused by that post, but it doesn't matter as it looks like we've sorted the OP's problem.![]()
It's just that I wonder why they provided 2 parameters when one already includes the other?
The other reason I used Target is that intellisense works with an explicit declaration; not so with an 'As Object' variable.
We also know that a generic Object is slightly slower while vba resolves its underlying type, but so is using 'too many dots', as in Target.Worksheet.Name, as that also must be resolved. So not really sure which is the best way.
I really appreciated the input from everyone. I'm just beginning my adventure in VB and while I still have no clue what I'm doing I feel like I did learn from this.
thanks again.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks