PC Review


Reply
Thread Tools Rate Thread

Alternative VBA to copy a worksheet

 
 
Graham Whitehead
Guest
Posts: n/a
 
      30th Oct 2007
Hi,

I am having some problems with some code I wrote a while back which has, up
unitl now, worked fine. The line is:

Sheets("Year to Date").Copy Before:=Sheets(1)

if there a generic way to copy a worksheet and move it to the first
posistion, i.e. the worksheet foremost to the left, without having to
specifiy Before:=Sheets(1) - as I am sure this is causing the problem.

Many thanks


 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      30th Oct 2007
That's the only way. Before should not cause you a problem. Maybe there is
something in the code causing it.


--
HTH

Bob

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

"Graham Whitehead" <(E-Mail Removed)> wrote in message
news:%23c3m$$(E-Mail Removed)...
> Hi,
>
> I am having some problems with some code I wrote a while back which has,
> up
> unitl now, worked fine. The line is:
>
> Sheets("Year to Date").Copy Before:=Sheets(1)
>
> if there a generic way to copy a worksheet and move it to the first
> posistion, i.e. the worksheet foremost to the left, without having to
> specifiy Before:=Sheets(1) - as I am sure this is causing the problem.
>
> Many thanks
>
>



 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      30th Oct 2007
This is an excerpt from VBA help on copying sheets.

If you don't specify either Before or After, Microsoft Excel creates a new
workbook that contains the copied sheet.

So it looks like you have to specify where you want it if you want it in the
same workbook. If you are having problems with that syntax, try using the
sheet name instead of the index number.

"Graham Whitehead" wrote:

> Hi,
>
> I am having some problems with some code I wrote a while back which has, up
> unitl now, worked fine. The line is:
>
> Sheets("Year to Date").Copy Before:=Sheets(1)
>
> if there a generic way to copy a worksheet and move it to the first
> posistion, i.e. the worksheet foremost to the left, without having to
> specifiy Before:=Sheets(1) - as I am sure this is causing the problem.
>
> Many thanks
>
>
>

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      30th Oct 2007
If you don't include the Befrroe or After excel puts the new worksheet in a
new wrokbook. I don't think that is what you want.

"Bob Phillips" wrote:

> That's the only way. Before should not cause you a problem. Maybe there is
> something in the code causing it.
>
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Graham Whitehead" <(E-Mail Removed)> wrote in message
> news:%23c3m$$(E-Mail Removed)...
> > Hi,
> >
> > I am having some problems with some code I wrote a while back which has,
> > up
> > unitl now, worked fine. The line is:
> >
> > Sheets("Year to Date").Copy Before:=Sheets(1)
> >
> > if there a generic way to copy a worksheet and move it to the first
> > posistion, i.e. the worksheet foremost to the left, without having to
> > specifiy Before:=Sheets(1) - as I am sure this is causing the problem.
> >
> > Many thanks
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBRLg==?=
Guest
Posts: n/a
 
      30th Oct 2007
When you look in the VBAProject is there a Sheet1(TabName) or Sheet*(Sheet1).
It could be someone deleted the worksheet you code is referring to.
--
Mike Q.


"Graham Whitehead" wrote:

> Hi,
>
> I am having some problems with some code I wrote a while back which has, up
> unitl now, worked fine. The line is:
>
> Sheets("Year to Date").Copy Before:=Sheets(1)
>
> if there a generic way to copy a worksheet and move it to the first
> posistion, i.e. the worksheet foremost to the left, without having to
> specifiy Before:=Sheets(1) - as I am sure this is causing the problem.
>
> Many thanks
>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      31st Oct 2007
But he did use Before? And the whole point of the question was to ask if he
could achieve that result some other way.

--
HTH

Bob

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

"Joel" <(E-Mail Removed)> wrote in message
news:3445CAD6-111E-4C94-8A0C-(E-Mail Removed)...
> If you don't include the Befrroe or After excel puts the new worksheet in
> a
> new wrokbook. I don't think that is what you want.
>
> "Bob Phillips" wrote:
>
>> That's the only way. Before should not cause you a problem. Maybe there
>> is
>> something in the code causing it.
>>
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Graham Whitehead" <(E-Mail Removed)> wrote in message
>> news:%23c3m$$(E-Mail Removed)...
>> > Hi,
>> >
>> > I am having some problems with some code I wrote a while back which
>> > has,
>> > up
>> > unitl now, worked fine. The line is:
>> >
>> > Sheets("Year to Date").Copy Before:=Sheets(1)
>> >
>> > if there a generic way to copy a worksheet and move it to the first
>> > posistion, i.e. the worksheet foremost to the left, without having to
>> > specifiy Before:=Sheets(1) - as I am sure this is causing the problem.
>> >
>> > Many thanks
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:02 AM
Google Adsense Alternative - Commission Junction Alternative -ClickBank Alternative William9999 Windows XP Performance 0 2nd Nov 2010 09:01 AM
How do I paste alternative columns from one worksheet to another? Felix Microsoft Excel Misc 1 7th Apr 2009 10:30 AM
alternative file.copy =?Utf-8?B?bHVpcyBtb2xpbmEgTWljYXNvZnQ=?= Microsoft VB .NET 9 18th Oct 2004 07:24 PM
Alternative to links for updating worksheet? =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 0 21st Jul 2004 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 AM.