Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Why doesn't While ActiveWorkBook < Null work?

I load a random number of csv files into Excel anywhere from 10 to 50

Excel shows that each csv file is loaded as a different workbook. each
workbook only has one worksheet

I want to execute a sub on each workbook and then write the created sheet and
close the workbook and repeat for the next workbook until I process all loaded
workbooks

The below macro does that but when all the workbooks are processed the while
loop will not end an trys to execute the subroutines on a blank no workbook
screen

How can I get the macro to stop when all the workbooks have been processed?

Thanks for any help.

Dennis

Sub xTBVarItemMxMnBtALL()

'====================================
' 05/26/2007
'Executes the below subs for each loaded workbook
'Sub xTopBotVarITemMxMnBoot()
'Sub WriteSheetandclose()
'===================================
On Error Resume Next
Dim curwk As Worksheet
Dim curwkbk As Workbook

Set curwkbk = ActiveWorkbook
While curwkbk < Null
Call xTopBotVarITemMxMnBoot
Call WriteSheetandClose
Set curwkbk = ActiveWorkbook
Wend
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Why doesn't While ActiveWorkBook < Null work?

Perhaps ActiveWorkbook is not really NULL?? If there were no workbooks open,
then what workbook would host the xTBVarItemMxMnBtALL?

--
Gary''s Student - gsnu200725


" wrote:

I load a random number of csv files into Excel anywhere from 10 to 50

Excel shows that each csv file is loaded as a different workbook. each
workbook only has one worksheet

I want to execute a sub on each workbook and then write the created sheet and
close the workbook and repeat for the next workbook until I process all loaded
workbooks

The below macro does that but when all the workbooks are processed the while
loop will not end an trys to execute the subroutines on a blank no workbook
screen

How can I get the macro to stop when all the workbooks have been processed?

Thanks for any help.

Dennis

Sub xTBVarItemMxMnBtALL()

'====================================
' 05/26/2007
'Executes the below subs for each loaded workbook
'Sub xTopBotVarITemMxMnBoot()
'Sub WriteSheetandclose()
'===================================
On Error Resume Next
Dim curwk As Worksheet
Dim curwkbk As Workbook

Set curwkbk = ActiveWorkbook
While curwkbk < Null
Call xTopBotVarITemMxMnBoot
Call WriteSheetandClose
Set curwkbk = ActiveWorkbook
Wend
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Why doesn't While ActiveWorkBook < Null work?

The Below Works

Sub xTBVarItemMxMnBtALL()

'====================================
' 05/26/2007
'Executes the below subs for each workbook
'Sub xTopBotVarITemMxMnBoot()
'Sub WriteSheetandclose()
'===================================
On Error Resume Next
Dim curwk As Worksheet
Dim curwkbk As Workbook
Dim ii As Integer

ii=0
Set curwkbk = ActiveWorkbook
While ii = 0
Call xTopBotVarITemMxMnBoot
Call WriteSheetandClose
Set curwkbk = ActiveWorkbook
If Len(curwkbk.Sheets(1).Name) = 0 Then Exit Sub
Wend

End Sub

wrote:

I load a random number of csv files into Excel anywhere from 10 to 50

Excel shows that each csv file is loaded as a different workbook. each
workbook only has one worksheet

I want to execute a sub on each workbook and then write the created sheet and
close the workbook and repeat for the next workbook until I process all loaded
workbooks

The below macro does that but when all the workbooks are processed the while
loop will not end an trys to execute the subroutines on a blank no workbook
screen

How can I get the macro to stop when all the workbooks have been processed?

Thanks for any help.

Dennis

Sub xTBVarItemMxMnBtALL()

'====================================
' 05/26/2007
'Executes the below subs for each loaded workbook
'Sub xTopBotVarITemMxMnBoot()
'Sub WriteSheetandclose()
'===================================
On Error Resume Next
Dim curwk As Worksheet
Dim curwkbk As Workbook

Set curwkbk = ActiveWorkbook
While curwkbk < Null
Call xTopBotVarITemMxMnBoot
Call WriteSheetandClose
Set curwkbk = ActiveWorkbook
Wend
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
ActiveWorkbook.RefreshAll nc Excel Discussion (Misc queries) 0 March 21st 06 10:50 AM
Not apply macro to every worksheet in activeworkbook G Setting up and Configuration of Excel 2 November 28th 05 05:36 PM
ActiveWorkbook.Protect password:=range("rangename") does not work WimR Excel Discussion (Misc queries) 1 June 26th 05 08:47 AM
ActiveWorkBook Pete Excel Discussion (Misc queries) 3 May 9th 05 04:14 PM
For Each wks In ActiveWorkbook.Worksheets bar a specific one? Pank Mehta Excel Discussion (Misc queries) 4 March 30th 05 04:53 PM


All times are GMT +1. The time now is 06:51 AM.

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"