View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Run two macros for two different sheets

On Thursday, July 24, 2014 8:59:01 AM UTC-7, GS wrote:
Note that whenever you need a reusable procedure to process

conditionally, it must implement input args that pass values provided

by the caller! I'd prefer that the reusable procedure *not* use

hard-coded range refs but I ignored this to keep the sample simple.

Normally, such a procedure would be used to provide global app

functionality and so more args would be used. Since your hard-coded

range refs are identical I didn't see any point to make things more

complex than needed...



--

Garry



Hi Garry,

Very interesting! I don't think I've seen a concept like that, or if I did, I did not understand what I was looking at.

And I don't fully grasp all of the magic of this little gem.

One thing that could be a problem is where "Size" in this line returns 2.

.Range("A2").Resize(lRow, Size).Cut .Cells(1, 1)

On sheet 1 if there is data in column B it is deleted in row 1 each time the code is run. (I can't figure how Size is set to 2)

But the 2 is good for sheet 2 where there is two columns of data.

Seems unlikely Size could return the number of columns the user wants per sheet, for example:

Sheet 1 Size = 1
Sheet 2 Size = 3
Sheet 3 Size = 2
Sheet 4 Size = .EntireRow

So, with these examples here, would the user need to "Input" by some manner the number of columns?

Is this where named ranges come into play? Or InputBoxs?

Howard