Sorting Columns Independently Followup From 3/13

C

curtc.

I need to add a line to the macro, so that it only works on a sheet named
"sort". This is so if the short cut to run the macro is run by accident (when
another sheet tab is the current worksheet) it only affects the data on the
"sort" worksheet. How do you identify which sheet of a workbook a macro is
assigned to run in...and that sheet only, even if you are working in another
worksheet (same workbook though)?
 
S

Stefi

Insert this line as 1st line of your macro:
Worksheets("sort").Select
Regards,
Stefi


„curtc.†ezt írta:
 
D

Dave Peterson

I think it would be better to qualify your ranges.

Instead of

range("A1:B99").sort key1:=range("a1"), ...

use

with worksheets("Sort")
.range("a1:B99").sort key1:=.range("A1"), ....
end with

The dots in front of those .Range()'s means that they belong to the object in
the previous with. In this case, that's the Sort worksheet.

If you have trouble adjusting your code, post what you have and I'm sure you'll
get help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top