Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Copying worksheet with macro

Hi - am hoping that someone can help out with this one.
I have a proforma workbook (referral form) that has a macro button that
saves into another workbook using cell references as the new workbook name
eg. Tom 1-Nov-08. The referral form then closes and the new worksheet stays
open.
The user will contiue entering data into the new workbook. The problem is
that there is another macro that copies and pastes data to a 'dump' file,
however this macro refers to the 'referral form' as the source workbook. I
will be creating new workbooks all the time from the 'referral form' all with
different workbook names.
I don't want to use the Personal.xls as several users will be using the
workbooks and they could be from different PCs.
Is there an active worksheet reference that I could use.
Hope this is clear. Using Excel 2003.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Copying worksheet with macro

I don't use statements like this in my code because it is too many characters

Workbooks("Referal forms").Sheets("Sheet1")

Instead I will do this at the beginning of my macro

set REFBk = Workbooks("Referal forms")
set REFSht = REFBk.sheets("Sheet1")

then in my code use either

with REFSht
.Range("A1") = 1
end with

or
REFSht.Range("A1") = 1



This will allow me to change the name of the workbook or worksheet without
going through the entire code and change every reference to the workbook or
sheet name.

In your case you can do something similar by putting in the beginning of the
code

Set REFBk = ActiveWorkBook

Then refer to this workbook by REFBk


You could also make the code use both

if XYZ = 1 then
Set REFBk = Workbooks("Referal forms")
else
Set REFBk = ActiveWorkBook
end if


"Janelle S" wrote:

Hi - am hoping that someone can help out with this one.
I have a proforma workbook (referral form) that has a macro button that
saves into another workbook using cell references as the new workbook name
eg. Tom 1-Nov-08. The referral form then closes and the new worksheet stays
open.
The user will contiue entering data into the new workbook. The problem is
that there is another macro that copies and pastes data to a 'dump' file,
however this macro refers to the 'referral form' as the source workbook. I
will be creating new workbooks all the time from the 'referral form' all with
different workbook names.
I don't want to use the Personal.xls as several users will be using the
workbooks and they could be from different PCs.
Is there an active worksheet reference that I could use.
Hope this is clear. Using Excel 2003.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Copying worksheet with macro

Hi,

"Is there an active worksheet reference"

yes,

ActiveWorkbook


--
Thanks,
Shane Devenshire


"Janelle S" wrote:

Hi - am hoping that someone can help out with this one.
I have a proforma workbook (referral form) that has a macro button that
saves into another workbook using cell references as the new workbook name
eg. Tom 1-Nov-08. The referral form then closes and the new worksheet stays
open.
The user will contiue entering data into the new workbook. The problem is
that there is another macro that copies and pastes data to a 'dump' file,
however this macro refers to the 'referral form' as the source workbook. I
will be creating new workbooks all the time from the 'referral form' all with
different workbook names.
I don't want to use the Personal.xls as several users will be using the
workbooks and they could be from different PCs.
Is there an active worksheet reference that I could use.
Hope this is clear. Using Excel 2003.

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
Copying worksheet cells into another worksheet using autofill SunnySD Excel Discussion (Misc queries) 3 September 10th 08 10:32 PM
Copying the active worksheet to another worksheet in the same work queenmaam Excel Worksheet Functions 5 March 25th 08 06:56 PM
Macro for Copying Worksheet to New Workbook MGC Excel Discussion (Misc queries) 10 August 17th 07 01:57 AM
Looking up a variable in one worksheet and copying information from another column to another worksheet?? Brad Torken Excel Discussion (Misc queries) 2 December 10th 06 06:02 AM
Copying a worksheet witrh protected cells to a new worksheet John Excel Worksheet Functions 2 February 1st 06 02:19 PM


All times are GMT +1. The time now is 06:47 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"