Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default File unable to open

Hi,

Something has gone wrong with excel vba codes below that unable to
open excel files from a list index in sheet(Main)

Extract of vba codes

Sheets("Main").Select
FileList = Cells(Rows.Count, 1).End(xlUp).Row
For Each Cell In Cells(1, 1).Resize(FileList, 1)
Filenm1 = Cell.Value

On Error Resume Next

With Application.FileSearch
.NewSearch

.LookIn = "J:\BBT\LO\Budget\Budget Actual\Acad"
.FileType = msoFileTypeExcelWorkbooks

.Filename = Filenm1 & "*.xls"
If .Execute 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through
all

Workbooks.Open (.FoundFiles(lCount))

ActiveWorkbook.Activate
Sheets("P+L").Select
Dim i As Long
Dim Lstrow As Long
Lstrow = Cells(Rows.Count, "A").End(xlUp).Row
If Lstrow 0 Then
For i = 5 To Lstrow
If Cells(i, 1).Value < "" Then
Cells(i, 1).Copy
Cells(i, 2).Select
ActiveSheet.Paste
Application.CutCopyMode = False
'Cells(i, 1).ClearContents
End If
Next
Else
MsgBox "It appears that the file is empty, check the file again"
End If

Any helps will be appreciated as I'm excel vba beginner

Thanks in advance

Regards
Len
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default File unable to open

Any chance you're now using xl2007?

If you are, then application.filesearch won't work anymore.

Ron de Bruin shares some alternatives he

http://www.rondebruin.nl/fso.htm
and
http://www.rondebruin.nl/copy3.htm

Len wrote:

Hi,

Something has gone wrong with excel vba codes below that unable to
open excel files from a list index in sheet(Main)

Extract of vba codes

Sheets("Main").Select
FileList = Cells(Rows.Count, 1).End(xlUp).Row
For Each Cell In Cells(1, 1).Resize(FileList, 1)
Filenm1 = Cell.Value

On Error Resume Next

With Application.FileSearch
.NewSearch

.LookIn = "J:\BBT\LO\Budget\Budget Actual\Acad"
.FileType = msoFileTypeExcelWorkbooks

.Filename = Filenm1 & "*.xls"
If .Execute 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through
all

Workbooks.Open (.FoundFiles(lCount))

ActiveWorkbook.Activate
Sheets("P+L").Select
Dim i As Long
Dim Lstrow As Long
Lstrow = Cells(Rows.Count, "A").End(xlUp).Row
If Lstrow 0 Then
For i = 5 To Lstrow
If Cells(i, 1).Value < "" Then
Cells(i, 1).Copy
Cells(i, 2).Select
ActiveSheet.Paste
Application.CutCopyMode = False
'Cells(i, 1).ClearContents
End If
Next
Else
MsgBox "It appears that the file is empty, check the file again"
End If

Any helps will be appreciated as I'm excel vba beginner

Thanks in advance

Regards
Len


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default File unable to open

On Jan 28, 9:40*pm, Dave Peterson wrote:
Any chance you're now using xl2007?

If you are, then application.filesearch won't work anymore.

Ron de Bruin shares some alternatives he

http://www.rondebruin.nl/fso.htm
andhttp://www.rondebruin.nl/copy3.htm





Len wrote:

Hi,


Something has gone wrong with excel vba codes below that unable to
open excel files from a list index in sheet(Main)


Extract of vba codes


* * Sheets("Main").Select
* * FileList = Cells(Rows.Count, 1).End(xlUp).Row
* * For Each Cell In Cells(1, 1).Resize(FileList, 1)
* * Filenm1 = Cell.Value


* * On Error Resume Next


* * * * With Application.FileSearch
* * * * * * .NewSearch


* * * * * * .LookIn = "J:\BBT\LO\Budget\Budget Actual\Acad"
* * * * * * .FileType = msoFileTypeExcelWorkbooks


* * * * * * .Filename = Filenm1 & "*.xls"
* * * * * * * * If .Execute 0 Then 'Workbooks in folder
* * * * * * * * * * For lCount = 1 To .FoundFiles..Count 'Loop through
all


* * * * * * * * * * * * Workbooks.Open (.FoundFiles(lCount))


* * ActiveWorkbook.Activate
* * Sheets("P+L").Select
* * Dim i As Long
* * Dim Lstrow As Long
* * Lstrow = Cells(Rows.Count, "A").End(xlUp).Row
* * If Lstrow 0 Then
* * For i = 5 To Lstrow
* * If Cells(i, 1).Value < "" Then
* * Cells(i, 1).Copy
* * Cells(i, 2).Select
* * ActiveSheet.Paste
* * Application.CutCopyMode = False
* * 'Cells(i, 1).ClearContents
* * End If
* * Next
* * Else
* * *MsgBox "It appears that the file is empty, check the file again"
* * End If


Any helps will be appreciated as I'm excel vba beginner


Thanks in advance


Regards
Len


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Hi Dave,

Thanks for your advice.

I try to work around with the appropriate codes and will see later

Regards
Len
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
UNABLE TO OPEN .CHM HELP FILE velvetlady Excel Discussion (Misc queries) 0 July 10th 09 06:48 PM
unable to open file Bluefish00 Excel Worksheet Functions 4 June 26th 08 12:59 PM
Unable to open file samb Excel Discussion (Misc queries) 0 March 16th 06 09:35 AM
Unable to open excel file and when view the file size show as 1 KB Kamal Siva Excel Discussion (Misc queries) 1 March 7th 06 03:23 AM
unable to open file MikeJohnB Excel Programming 0 May 4th 05 08:20 PM


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