Looking to simplify the following code possibly with For-Next Loop.
Where the My Subs are private sub procedures. Thanks.![]()
Please Login or Register to view this content.
Looking to simplify the following code possibly with For-Next Loop.
Where the My Subs are private sub procedures. Thanks.![]()
Please Login or Register to view this content.
This question was also asked at
http://www.mrexcel.com/forum/showthread.php?t=328091
There are a couple of options there, both use Application.Run
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Hi
Try this....
rylo![]()
Please Login or Register to view this content.
thanks for the response. What if the sheets were named (ex. "A", "B", "C" etc...) instead of numbered?
Hi
Does the macro have the same suffix as the sheet (ie A,B...) or does it still have the number suffix?
rylo
sorry, but i tried to give a generic example in the first code section. code looks more like this. thanks.
![]()
Please Login or Register to view this content.
You can convert numbers to alpha characters using the Chr VBA function. Using Rylo's code above, as well as your example for sheets A-D, you could use:
Chr(65) = "A"![]()
Please Login or Register to view this content.
Chr(66) = "B"
etc.
HTH
Jason
How much simpler could it be?
... would be more like obscure than good practice.![]()
Please Login or Register to view this content.
What if subs are private?
doesnt work the same as![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
The first example doesn't work at all, for the same reason you can't do this:
![]()
Please Login or Register to view this content.
looking to call the sub (in arr2) which corresponds to the correct sheet(arr1), however error message says that a sub, function or property is expected after the call command. thanks.
![]()
Please Login or Register to view this content.
Hi
Try changing
to![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
actually shouldn't it be
rylo![]()
Please Login or Register to view this content.
rylo the first part of your suggestion works as far as activating the sheets however the second array (arr2) is an array of private subs which for some reason arent called in the examples above.
Hi
Being lazy here - can you put up an example workbook with the subs, sheets etc.
rylo
hey rylo-- i have completely solved my problem for this post. i re-worked it more like your most recent post and got it to work. Thanks again.
how bout this one. this is a simplified version.
i tried to do the standard concatenation but the compiler didnt like the fact that the new line started with quotes.![]()
Please Login or Register to view this content.
didnt work for me.![]()
Please Login or Register to view this content.
i tried to add this code to the previous post to eliminate the compile error but, i get new compile error: syntax error. any thoughts. thanks.
![]()
Please Login or Register to view this content.
VB does not treat strings resulting from concatenation as variables.
VB does not treat strings resulting from concatenation as properties, methods, functions, collections, or objects.
The approach you have been trying throughout this thread (refering to the argument a_1 as "a_" & "1") is fatally flawed.
If you describe what you are trying to do, a successful approach (probably involving arrays) might be found.
Last edited by mikerickson; 07-12-2008 at 07:07 PM.
mike--
is there any way to reduce the redundancy then? thanks. bud.
You should look into arrays.
The code above could be done like this:This could be further simplified, to one loop![]()
Please Login or Register to view this content.
Starting with arrays and using For..Next loops makes it easier to see this version.![]()
Please Login or Register to view this content.
Unless you need myRange or formulaString later in the routine, this would be the way to go.![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks