Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Creating WBooks

Hi
From a cmdbutton on a form I am simply trying to create a new workbook and
copy a sheet (not necessarily sheet1) from original to new sheet1 (always).
What happens is that 2 wbooks are created - the first is blank, the second
with the required sheet copied. Why is this and how should my code be
amended?

The code is:

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks.Add
Workbooks(cFilename).Sheets(1).Copy
ThisWorkbook.Sheets(1).Paste
End If
End Sub

i would appreciate any advice. T.I.A

Geoff
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Creating WBooks

Hi Ardus
Understand that now.
But what happens is there is only one sheet in the new workbook and i need
my standard 3. In the sample code the 1st new wbook was standard num of
sheets but blank, the second was data copied but only 1 sheet. Sorry should
have mentioned that.

Geoff

"Ardus Petus" wrote:

The instruction:
Workbooks(cFilename).Sheets(1).Copy
creates a new workbook and copies sheets(1) into it

HTH
--
AP

"Geoff" a écrit dans le message de news:
...
Hi
From a cmdbutton on a form I am simply trying to create a new workbook and
copy a sheet (not necessarily sheet1) from original to new sheet1
(always).
What happens is that 2 wbooks are created - the first is blank, the second
with the required sheet copied. Why is this and how should my code be
amended?

The code is:

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks.Add
Workbooks(cFilename).Sheets(1).Copy
ThisWorkbook.Sheets(1).Paste
End If
End Sub

i would appreciate any advice. T.I.A

Geoff




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Creating WBooks

All you need is

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks(cFilename).Sheets(1).Copy
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Geoff" wrote in message
...
Hi Ardus
Understand that now.
But what happens is there is only one sheet in the new workbook and i need
my standard 3. In the sample code the 1st new wbook was standard num of
sheets but blank, the second was data copied but only 1 sheet. Sorry

should
have mentioned that.

Geoff

"Ardus Petus" wrote:

The instruction:
Workbooks(cFilename).Sheets(1).Copy
creates a new workbook and copies sheets(1) into it

HTH
--
AP

"Geoff" a écrit dans le message de

news:
...
Hi
From a cmdbutton on a form I am simply trying to create a new workbook

and
copy a sheet (not necessarily sheet1) from original to new sheet1
(always).
What happens is that 2 wbooks are created - the first is blank, the

second
with the required sheet copied. Why is this and how should my code be
amended?

The code is:

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks.Add
Workbooks(cFilename).Sheets(1).Copy
ThisWorkbook.Sheets(1).Paste
End If
End Sub

i would appreciate any advice. T.I.A

Geoff






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Creating WBooks

Hi Bob
but that only creates a wbook with 1 sheet and I want to have the std 3.

Geoff

"Bob Phillips" wrote:

All you need is

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks(cFilename).Sheets(1).Copy
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Geoff" wrote in message
...
Hi Ardus
Understand that now.
But what happens is there is only one sheet in the new workbook and i need
my standard 3. In the sample code the 1st new wbook was standard num of
sheets but blank, the second was data copied but only 1 sheet. Sorry

should
have mentioned that.

Geoff

"Ardus Petus" wrote:

The instruction:
Workbooks(cFilename).Sheets(1).Copy
creates a new workbook and copies sheets(1) into it

HTH
--
AP

"Geoff" a écrit dans le message de

news:
...
Hi
From a cmdbutton on a form I am simply trying to create a new workbook

and
copy a sheet (not necessarily sheet1) from original to new sheet1
(always).
What happens is that 2 wbooks are created - the first is blank, the

second
with the required sheet copied. Why is this and how should my code be
amended?

The code is:

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks.Add
Workbooks(cFilename).Sheets(1).Copy
ThisWorkbook.Sheets(1).Paste
End If
End Sub

i would appreciate any advice. T.I.A

Geoff








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Creating WBooks

Private Sub cmdExecute_Click()
Workbooks.Add
Windows("Book1").Activate
Cells.Copy
Windows("Book2").Activate
ActiveSheet.Paste
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Geoff" wrote in message
...
Hi Bob
but that only creates a wbook with 1 sheet and I want to have the std 3.

Geoff

"Bob Phillips" wrote:

All you need is

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks(cFilename).Sheets(1).Copy
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Geoff" wrote in message
...
Hi Ardus
Understand that now.
But what happens is there is only one sheet in the new workbook and i

need
my standard 3. In the sample code the 1st new wbook was standard num

of
sheets but blank, the second was data copied but only 1 sheet. Sorry

should
have mentioned that.

Geoff

"Ardus Petus" wrote:

The instruction:
Workbooks(cFilename).Sheets(1).Copy
creates a new workbook and copies sheets(1) into it

HTH
--
AP

"Geoff" a écrit dans le message de

news:
...
Hi
From a cmdbutton on a form I am simply trying to create a new

workbook
and
copy a sheet (not necessarily sheet1) from original to new sheet1
(always).
What happens is that 2 wbooks are created - the first is blank,

the
second
with the required sheet copied. Why is this and how should my

code be
amended?

The code is:

Private Sub cmdExecute_Click()
If chkConfirm = True Then
cFilename = ThisWorkbook.Name
Workbooks.Add
Workbooks(cFilename).Sheets(1).Copy
ThisWorkbook.Sheets(1).Paste
End If
End Sub

i would appreciate any advice. T.I.A

Geoff








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a new key kate Excel Discussion (Misc queries) 1 August 28th 09 10:48 AM
Creating an add-in HSalim[MVP] Excel Programming 22 December 29th 05 09:54 PM
Creating ActualSelf Excel Discussion (Misc queries) 1 October 20th 05 08:03 PM
show list of wbooks present into a dir sal21[_74_] Excel Programming 1 September 22nd 05 01:02 AM
Help with creating a VBA paritoshmehta[_2_] Excel Programming 7 March 6th 04 01:21 PM


All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"