Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Worksheet names in VBA

Excel 2003 SR 1

Limited VBA skills

I'm recording a macro where I open two worksheets within a workbook, and
arrange them horizontally. I move Column I to K, J to C, etc from the top
workbook to the bottom one. It works fine in the macro, but I noticed that
the name of the workbook is in the VBA - i.e.
Windows("DRAWDOWN MACRO TEST.xls:2").Activate
Columns("I:I").Select
Selection.Copy
Windows("DRAWDOWN MACRO TEST.xls:1").Activate
Range("K1").Select
ActiveSheet.Paste

Can I (and how can I) remove the reference to the name of the workbook?
This is in test mode now, but when it goes into production, the names will
change each week.

TIA,

CaroleO
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Worksheet names in VBA

Don't go through the windows collection. Just refer to the worksheet names:

worksheets("sheet1").range("I:I").copy _
destination:=worksheets("sheet2").range("K1")

(and this drops the selections at the same time.)

CaroleO wrote:

Excel 2003 SR 1

Limited VBA skills

I'm recording a macro where I open two worksheets within a workbook, and
arrange them horizontally. I move Column I to K, J to C, etc from the top
workbook to the bottom one. It works fine in the macro, but I noticed that
the name of the workbook is in the VBA - i.e.
Windows("DRAWDOWN MACRO TEST.xls:2").Activate
Columns("I:I").Select
Selection.Copy
Windows("DRAWDOWN MACRO TEST.xls:1").Activate
Range("K1").Select
ActiveSheet.Paste

Can I (and how can I) remove the reference to the name of the workbook?
This is in test mode now, but when it goes into production, the names will
change each week.

TIA,

CaroleO


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Worksheet names in VBA

you can use worksheets("...").Activate By using this you can either use the
worksheets name, or "position" (kind of like using the value in a cell or
Excel's designation for that cell).

"CaroleO" wrote:

Excel 2003 SR 1

Limited VBA skills

I'm recording a macro where I open two worksheets within a workbook, and
arrange them horizontally. I move Column I to K, J to C, etc from the top
workbook to the bottom one. It works fine in the macro, but I noticed that
the name of the workbook is in the VBA - i.e.
Windows("DRAWDOWN MACRO TEST.xls:2").Activate
Columns("I:I").Select
Selection.Copy
Windows("DRAWDOWN MACRO TEST.xls:1").Activate
Range("K1").Select
ActiveSheet.Paste

Can I (and how can I) remove the reference to the name of the workbook?
This is in test mode now, but when it goes into production, the names will
change each week.

TIA,

CaroleO

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Worksheet names in VBA

Thanks, Dave and Brent - I'll give this a try!

CaroleO

"Dave Peterson" wrote:

Don't go through the windows collection. Just refer to the worksheet names:

worksheets("sheet1").range("I:I").copy _
destination:=worksheets("sheet2").range("K1")

(and this drops the selections at the same time.)

CaroleO wrote:

Excel 2003 SR 1

Limited VBA skills

I'm recording a macro where I open two worksheets within a workbook, and
arrange them horizontally. I move Column I to K, J to C, etc from the top
workbook to the bottom one. It works fine in the macro, but I noticed that
the name of the workbook is in the VBA - i.e.
Windows("DRAWDOWN MACRO TEST.xls:2").Activate
Columns("I:I").Select
Selection.Copy
Windows("DRAWDOWN MACRO TEST.xls:1").Activate
Range("K1").Select
ActiveSheet.Paste

Can I (and how can I) remove the reference to the name of the workbook?
This is in test mode now, but when it goes into production, the names will
change each week.

TIA,

CaroleO


--

Dave Peterson

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
using the Excel generic worksheet names instead of user-given names in code Paul Excel Discussion (Misc queries) 5 June 26th 09 08:44 PM
MAKE A LIST OF NAMES FROM REPEATED NAMES IN THE SAME WORKSHEET r.kordahi Excel Discussion (Misc queries) 2 January 3rd 09 08:10 AM
Changing VB Component Names to match Worksheet names using VBE Philip Excel Programming 1 April 12th 05 05:37 PM
return all worksheet tab names and chart sheet tab names in report - an example DataFreakFromUtah Excel Programming 2 October 6th 04 08:09 PM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_2_] Excel Programming 2 September 22nd 04 03:30 PM


All times are GMT +1. The time now is 11:24 PM.

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"