#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Macro code

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 695
Default Macro code

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Macro code

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro code

The best way to switch back-and-forth bedtween a new workbook and the active
workbook is like this

workbooks.open myfilename
set wbk = activeworkbook 'this is the recently opened book
Thisworkbook.activate 'selects the workbook where the macro is located
wbk.activate 'back to the opened workbook

"Shu of AZ" wrote:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Macro code

wildcard for workbooks with an extension of csv?

"Shu of AZ" wrote:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 695
Default Macro code

Sub findWB()
For Each wb In Workbooks
If Right(wb.Name, 3) = "csv" Then csvBook = wb.Name
Next
Workbooks(csvBook).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Macro code

Thanks excelent,
When I place this into the macro I use, it returns an error stating and
referring to the line, For Each wb In Workbooks, "variable not defined" and
highlighting 'wb'.
Would that be a DIM statement and if so what type, string???? etc.

"excelent" wrote:

Sub findWB()
For Each wb In Workbooks
If Right(wb.Name, 3) = "csv" Then csvBook = wb.Name
Next
Workbooks(csvBook).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro code

A CSV file when opened in Excel looks like a workbook. It is always a good
idea immediately after opening a new workbook to set a variable to the
activeworkbook so you can easily switch back and forth between different
workbooks.

"Shu of AZ" wrote:

wildcard for workbooks with an extension of csv?

"Shu of AZ" wrote:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Macro code

Thanks again, I figured out the definition of the variables

"excelent" wrote:

Sub findWB()
For Each wb In Workbooks
If Right(wb.Name, 3) = "csv" Then csvBook = wb.Name
Next
Workbooks(csvBook).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

The first loaded workbook changes names daily and there may be many other
workbooks open. Only one will have the .csv extension

"excelent" wrote:

Copy from first loaded workbook (1) to active workbook

Sub xCopy()
Workbooks(1).Sheets(1).Cells.Copy ActiveWorkbook.ActiveSheet.Cells
End Sub


"Shu of AZ" skrev:

In the example below, I am trying to go from a worksheet BOOK1.xls to another
worksheet already open Tup071130_hr.csv and copy then go back to BOOK1.xls
and paste the contents.
The worksheet i want to go to will be named something different each day but
end with .csv and will have 12 preceeding characters. Since it changes daily
I need to use a wildcard for the window name. I can't get a wildcard of any
type to work. Can anyone tell me how it should be worded in the macro to see
the open and new worksheet when it is open each day? Thanks in advance.

Windows("????????????.csv").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows("Book1").Activate
ActiveSheet.Paste

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
VBA code for macro help Cam Excel Discussion (Misc queries) 0 September 7th 07 07:14 PM
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Help With Macro Code?? Neil Smith Excel Worksheet Functions 1 August 24th 06 07:40 PM
Macro VB code help Anthony Excel Discussion (Misc queries) 4 October 8th 05 07:25 PM
Zip Code Macro Ken Wright Excel Worksheet Functions 0 December 9th 04 07:55 AM


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