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

I have created a macro code to formate my excel file below is the code

sub test()
ChDir "C:\N"
Workbooks.Open Filename:="C:\N\AU.xls"
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End sub

The above code work only in file AU.xls, i would like to have a short macro
code to open my other three files (BU.xls, DU.xls, EF.xls) and perform the
same action to it.

Is it possible to put the formate part in loop.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default open workbook

Try this untested code....

Sub test()

Dim intTemp As Integer
Dim arrWorkBook As Variant

arrWorkBook = Array("AU.xls", "BU.xls", "DU.xls", "EF.xls")

For intTemp = 0 To UBound(arrWorkBook)
Workbooks.Open Filename:="C:\N\" & arrWorkBook(intTemp)
Rows("1:1").Select
With Selection.Interior
..ColorIndex = 6
..Pattern = xlSolid
End With
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ranjith Kurian" wrote:

I have created a macro code to formate my excel file below is the code

sub test()
ChDir "C:\N"
Workbooks.Open Filename:="C:\N\AU.xls"
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End sub

The above code work only in file AU.xls, i would like to have a short macro
code to open my other three files (BU.xls, DU.xls, EF.xls) and perform the
same action to it.

Is it possible to put the formate part in loop.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default open workbook

thanks a lot

"Jacob Skaria" wrote:

Try this untested code....

Sub test()

Dim intTemp As Integer
Dim arrWorkBook As Variant

arrWorkBook = Array("AU.xls", "BU.xls", "DU.xls", "EF.xls")

For intTemp = 0 To UBound(arrWorkBook)
Workbooks.Open Filename:="C:\N\" & arrWorkBook(intTemp)
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ranjith Kurian" wrote:

I have created a macro code to formate my excel file below is the code

sub test()
ChDir "C:\N"
Workbooks.Open Filename:="C:\N\AU.xls"
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End sub

The above code work only in file AU.xls, i would like to have a short macro
code to open my other three files (BU.xls, DU.xls, EF.xls) and perform the
same action to it.

Is it possible to put the formate part in loop.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default open workbook

Cheers..

If this post helps click Yes
---------------
Jacob Skaria


"Ranjith Kurian" wrote:

thanks a lot

"Jacob Skaria" wrote:

Try this untested code....

Sub test()

Dim intTemp As Integer
Dim arrWorkBook As Variant

arrWorkBook = Array("AU.xls", "BU.xls", "DU.xls", "EF.xls")

For intTemp = 0 To UBound(arrWorkBook)
Workbooks.Open Filename:="C:\N\" & arrWorkBook(intTemp)
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ranjith Kurian" wrote:

I have created a macro code to formate my excel file below is the code

sub test()
ChDir "C:\N"
Workbooks.Open Filename:="C:\N\AU.xls"
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End sub

The above code work only in file AU.xls, i would like to have a short macro
code to open my other three files (BU.xls, DU.xls, EF.xls) and perform the
same action to it.

Is it possible to put the formate part in loop.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default open workbook

Try this

Sub test()
BookData = "BU.xls,DU.xls,EF.xls"
MyBook = Split(BookData, ",")
For x = 0 To UBound(MyBook)
Workbooks.Open Filename:="C:\N\" & MyBook(x)
ActiveSheet.Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
ActiveWorkbook.Close savechanges:=True
Next
End Sub

Mike

"Ranjith Kurian" wrote:

I have created a macro code to formate my excel file below is the code

sub test()
ChDir "C:\N"
Workbooks.Open Filename:="C:\N\AU.xls"
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End sub

The above code work only in file AU.xls, i would like to have a short macro
code to open my other three files (BU.xls, DU.xls, EF.xls) and perform the
same action to it.

Is it possible to put the formate part in loop.


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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation Marcello do Guzman[_3_] Excel Programming 2 December 5th 04 06:50 AM


All times are GMT +1. The time now is 02:30 PM.

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

About Us

"It's about Microsoft Excel"