Macros Tabs and Files

J

Jim

Hi. I created a Macro to take a excell file (lets same its named Doggy),
sort and break up per my specs and place results on 7 different tabs. Works
good. However everytime I get a new file to convert through this Macro I
have to rename the file to Doggy before the macroo will work because that is
the name on the tab when I origionally created the macro. Here is the line
that is causing the issue - Sheets("Doggy").Select . is there a way around
this?

Thanks
 
F

FSt1

hi,
when you "get a new file" is this a new file or an existing one that someone
sent to you? If a new file, how many sheets do you start with? by default,
new files have the first sheet as "sheet1". perhaps you could use sheet1 in
the macro and rename the sheet later to batty or hippopotamusy or what ever
if needed.
if only one sheet in the new file, then play a mind game with it.
For each sheet in activeworkbook
run macro
next
if no other sheets, you are out of the loop. end sub.

thought?
FSt1
 
N

Norman Jones

Hi Jim,

Try using ActiveWorkbook.

By the way, it is seldome necessary, or desirable, to
select object; It is usually possible to manipulate an
object variable rather than making a physical selection.
 
J

Jim

Sorry, the file is one that has been sent to me that I open and convert so
the name on the tab would be whatever the file name is.
 
B

Bob Phillips

Set StartSheet = Activesheet

'your code

StartSheet.Activate

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
J

Jim

Sorry, the file is one that has been sent to me that I open and convert so
the name on the tab would be whatever the file name is.

I start with one tab but have 8 when I am done converting the information.
Thank you.
 
T

Tom Ogilvy

To add to my original post:

Using Sheets(1) vice Sheets("Doggy") assumes that when you add sheets, you
add them after the orginal sheet.

if that isn't the case, you can add a line at the top of your macro

Sheets(1).Name = "Doggy"

or you can use the book name since you say they are the same

sheets(Left(activeworkbook.name,len(activeworkbook.name)-4).Select
 

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