Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Compile error - Expected: list seperator or )

Hi,

My below code has a compile error : Expected: list seperator or )
Pls help solve it.


Sub Consolidation()


'Copy to the next line in the target file'

Dim i As Integer, wb As Workbook
Dim first, last As Long

'Open all files in the folder'
With Application.FileSearch
.NewSearch
.LookIn = "N:\Tax\FILE1"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count

'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Identify 1st row & last row of the target area'
first = ActiveSheet.Cells(Rows.Count, "C").End(xlDown).Row
first = first - 1
last = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("A" & first&":H" & last).Copy ======
error in here

'On to the next workbook
Next i
End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Compile error - Expected: list seperator or )

Put a space between first and &.

Range("A" & first &":H" & last).Copy

Mike F
"diepvic" wrote in message
...
Hi,

My below code has a compile error : Expected: list seperator or )
Pls help solve it.


Sub Consolidation()


'Copy to the next line in the target file'

Dim i As Integer, wb As Workbook
Dim first, last As Long

'Open all files in the folder'
With Application.FileSearch
.NewSearch
.LookIn = "N:\Tax\FILE1"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count

'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Identify 1st row & last row of the target area'
first = ActiveSheet.Cells(Rows.Count, "C").End(xlDown).Row
first = first - 1
last = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("A" & first&":H" & last).Copy
======
error in here

'On to the next workbook
Next i
End With

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Compile error - Expected: list seperator or )

Also Dim first as Long.

Dim first, last As Long
Should be
Dim first As Long, last As Long

Otherwise first is Dimmed as Variant and only last is Dimmed as Long.

Also, any chance that first could = 1?
Then first = first - 1 would be in error.

Mike F

"Mike Fogleman" wrote in message
...
Put a space between first and &.

Range("A" & first &":H" & last).Copy

Mike F
"diepvic" wrote in message
...
Hi,

My below code has a compile error : Expected: list seperator or )
Pls help solve it.


Sub Consolidation()


'Copy to the next line in the target file'

Dim i As Integer, wb As Workbook
Dim first, last As Long

'Open all files in the folder'
With Application.FileSearch
.NewSearch
.LookIn = "N:\Tax\FILE1"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count

'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Identify 1st row & last row of the target area'
first = ActiveSheet.Cells(Rows.Count, "C").End(xlDown).Row
first = first - 1
last = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("A" & first&":H" & last).Copy ======
error in here

'On to the next workbook
Next i
End With

End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Compile error - Expected: list seperator or )

That's brilliant

Thx so much

One more question, after I open each workbook, I want to close it without
saving and no prompt message asking "Do u want to save ..?" . Also each time
when I open the workbook, I do not want to update the workbook so can you
advise me the code to avoid pop-up message asking "Do you want to update the
workbook...?"

Appreciate your help.

"Mike Fogleman" wrote:

Also Dim first as Long.

Dim first, last As Long
Should be
Dim first As Long, last As Long

Otherwise first is Dimmed as Variant and only last is Dimmed as Long.

Also, any chance that first could = 1?
Then first = first - 1 would be in error.

Mike F

"Mike Fogleman" wrote in message
...
Put a space between first and &.

Range("A" & first &":H" & last).Copy

Mike F
"diepvic" wrote in message
...
Hi,

My below code has a compile error : Expected: list seperator or )
Pls help solve it.


Sub Consolidation()


'Copy to the next line in the target file'

Dim i As Integer, wb As Workbook
Dim first, last As Long

'Open all files in the folder'
With Application.FileSearch
.NewSearch
.LookIn = "N:\Tax\FILE1"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count

'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Identify 1st row & last row of the target area'
first = ActiveSheet.Cells(Rows.Count, "C").End(xlDown).Row
first = first - 1
last = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("A" & first&":H" & last).Copy ======
error in here

'On to the next workbook
Next i
End With

End Sub






.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Compile error - Expected: list seperator or )

Simple enough, although I didn't see any Close code,

Set wb = Workbooks.Open(Filename:=.FoundFiles(i), UpdateLinks:=0)
wb.Close savechanges:=False

Mike F
"diepvic" wrote in message
...
That's brilliant

Thx so much

One more question, after I open each workbook, I want to close it without
saving and no prompt message asking "Do u want to save ..?" . Also each
time
when I open the workbook, I do not want to update the workbook so can you
advise me the code to avoid pop-up message asking "Do you want to update
the
workbook...?"

Appreciate your help.

"Mike Fogleman" wrote:

Also Dim first as Long.

Dim first, last As Long
Should be
Dim first As Long, last As Long

Otherwise first is Dimmed as Variant and only last is Dimmed as Long.

Also, any chance that first could = 1?
Then first = first - 1 would be in error.

Mike F

"Mike Fogleman" wrote in message
...
Put a space between first and &.

Range("A" & first &":H" & last).Copy

Mike F
"diepvic" wrote in message
...
Hi,

My below code has a compile error : Expected: list seperator or )
Pls help solve it.


Sub Consolidation()


'Copy to the next line in the target file'

Dim i As Integer, wb As Workbook
Dim first, last As Long

'Open all files in the folder'
With Application.FileSearch
.NewSearch
.LookIn = "N:\Tax\FILE1"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count

'Open each workbook
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Identify 1st row & last row of the target area'
first = ActiveSheet.Cells(Rows.Count, "C").End(xlDown).Row
first = first - 1
last = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("A" & first&":H" & last).Copy ======
error in here

'On to the next workbook
Next i
End With

End Sub






.



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
Compile Error:Expected Array Fatima CN Excel Programming 2 October 15th 09 03:23 AM
Launch external program - Compile error: Expected: list separator PJ Excel Programming 2 December 19th 08 05:31 PM
compile error - expected an array John Excel Programming 8 September 21st 06 08:04 PM
compile error: Expected: = ...Why? cesw[_2_] Excel Programming 3 September 10th 05 12:41 AM
Compile Error: Expected End Property George J[_3_] Excel Programming 4 August 3rd 05 03:35 PM


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