Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vsn Vsn is offline
external usenet poster
 
Posts: 21
Default Is Sheet Empty and unused

Hi all,

I was thinking is there a methode in VBA to see if a sheet has been used or
that it is empty so that i can remove it from the workbook knowing i do not
loose data or better rename it an put the next bunch of data comming?

Thx,
Ludovic


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Is Sheet Empty and unused

Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been used
or that it is empty so that i can remove it from the workbook knowing i do
not loose data or better rename it an put the next bunch of data comming?

Thx,
Ludovic

  #3   Report Post  
Posted to microsoft.public.excel.programming
Vsn Vsn is offline
external usenet poster
 
Posts: 21
Default Is Sheet Empty and unused

Unfortunatly I can't use this because i like to use the code from Access VBA
using late binding and that does not accept the 'Cells' in '.CountA(Cells)'

Are there any other methods which would be suitable to be used from Access.
I like to check if there are any empty sheets in the workbook to which i can
dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been used
or that it is empty so that i can remove it from the workbook knowing i
do not loose data or better rename it an put the next bunch of data
comming?

Thx,
Ludovic



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Is Sheet Empty and unused

I've not controlled Excel from another program before, so this is just a
guess... what about if you explicitly qualify the Cells property with
ActiveSheet property?

If Application.CountA(ActiveSheet.Cells) = 0 Then

--
Rick (MVP - Excel)


"Vsn" <vsn_hotmail_kom wrote in message
...
Unfortunatly I can't use this because i like to use the code from Access
VBA using late binding and that does not accept the 'Cells' in
'.CountA(Cells)'

Are there any other methods which would be suitable to be used from
Access. I like to check if there are any empty sheets in the workbook to
which i can dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been used
or that it is empty so that i can remove it from the workbook knowing i
do not loose data or better rename it an put the next bunch of data
comming?

Thx,
Ludovic




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Is Sheet Empty and unused

Here is an all VBA method to do what you want...


--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
I've not controlled Excel from another program before, so this is just a
guess... what about if you explicitly qualify the Cells property with
ActiveSheet property?

If Application.CountA(ActiveSheet.Cells) = 0 Then

--
Rick (MVP - Excel)


"Vsn" <vsn_hotmail_kom wrote in message
...
Unfortunatly I can't use this because i like to use the code from Access
VBA using late binding and that does not accept the 'Cells' in
'.CountA(Cells)'

Are there any other methods which would be suitable to be used from
Access. I like to check if there are any empty sheets in the workbook to
which i can dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been
used or that it is empty so that i can remove it from the workbook
knowing i do not loose data or better rename it an put the next bunch
of data comming?

Thx,
Ludovic







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Is Sheet Empty and unused

Here is an all VBA method to do what you want...

If ActiveSheet.Cells.Find(What:="*", LookIn:=xlFormulas) Is Nothing Then
MsgBox "All cells are empty"
Else
MsgBox "There is data on this worksheet"
End If

Note that this also uses ActiveSheet.Cells, but it does not try to use it
inside a worksheet function call. By the way, in both this and my previous
message, I am assuming that you are going to "vector" your calls to the
Excel objects through the variable that you have set up for referencing
Excel.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
I've not controlled Excel from another program before, so this is just a
guess... what about if you explicitly qualify the Cells property with
ActiveSheet property?

If Application.CountA(ActiveSheet.Cells) = 0 Then

--
Rick (MVP - Excel)


"Vsn" <vsn_hotmail_kom wrote in message
...
Unfortunatly I can't use this because i like to use the code from Access
VBA using late binding and that does not accept the 'Cells' in
'.CountA(Cells)'

Are there any other methods which would be suitable to be used from
Access. I like to check if there are any empty sheets in the workbook to
which i can dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been
used or that it is empty so that i can remove it from the workbook
knowing i do not loose data or better rename it an put the next bunch
of data comming?

Thx,
Ludovic





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Is Sheet Empty and unused

For the OP:

....and don't forget to replace any Excel constants such as xlFormulas with
their values.

Tim

"Rick Rothstein" wrote in message
...
Here is an all VBA method to do what you want...

If ActiveSheet.Cells.Find(What:="*", LookIn:=xlFormulas) Is Nothing Then
MsgBox "All cells are empty"
Else
MsgBox "There is data on this worksheet"
End If

Note that this also uses ActiveSheet.Cells, but it does not try to use it
inside a worksheet function call. By the way, in both this and my previous
message, I am assuming that you are going to "vector" your calls to the
Excel objects through the variable that you have set up for referencing
Excel.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
I've not controlled Excel from another program before, so this is just a
guess... what about if you explicitly qualify the Cells property with
ActiveSheet property?

If Application.CountA(ActiveSheet.Cells) = 0 Then

--
Rick (MVP - Excel)


"Vsn" <vsn_hotmail_kom wrote in message
...
Unfortunatly I can't use this because i like to use the code from Access
VBA using late binding and that does not accept the 'Cells' in
'.CountA(Cells)'

Are there any other methods which would be suitable to be used from
Access. I like to check if there are any empty sheets in the workbook to
which i can dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been
used or that it is empty so that i can remove it from the workbook
knowing i do not loose data or better rename it an put the next bunch
of data comming?

Thx,
Ludovic







  #8   Report Post  
Posted to microsoft.public.excel.programming
Vsn Vsn is offline
external usenet poster
 
Posts: 21
Default Is Sheet Empty and unused

Thanks for all advices. Finaly I managed like this:-

Dim objActiveWkbk As Object
Dim objXL As Object

Set objXL = CreateObject("Excel.Application")
Set objActiveWkbk = objXL.Application.ActiveWorkbook

If objXL.Application.CountA(objActiveWkbk.ActiveSheet .usedrange) = 0 then
..........


Cheers,
Ludovic

"Rick Rothstein" schreef in bericht
...
I've not controlled Excel from another program before, so this is just a
guess... what about if you explicitly qualify the Cells property with
ActiveSheet property?

If Application.CountA(ActiveSheet.Cells) = 0 Then

--
Rick (MVP - Excel)


"Vsn" <vsn_hotmail_kom wrote in message
...
Unfortunatly I can't use this because i like to use the code from Access
VBA using late binding and that does not accept the 'Cells' in
'.CountA(Cells)'

Are there any other methods which would be suitable to be used from
Access. I like to check if there are any empty sheets in the workbook to
which i can dump data, this before I just add a sheet to the collection.

Cheers,
Ludovic

"Otto Moehrbach" schreef in bericht
...
Try this macro. HTH Otto
Sub IsSheetEmpty()
If Application.CountA(Cells) = 0 Then
MsgBox "It's empty."
Else
MsgBox "It's not empty."
End If
End Sub


"Vsn" <vsn_hotmail_kom wrote in message
...
Hi all,

I was thinking is there a methode in VBA to see if a sheet has been
used or that it is empty so that i can remove it from the workbook
knowing i do not loose data or better rename it an put the next bunch
of data comming?

Thx,
Ludovic






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
Copy Data from Sheet 1 to Empty Cell in Sheet 2 dtoland Excel Programming 2 November 4th 09 06:48 PM
Copy row to first empty row in new sheet Taylor Excel Programming 3 July 22nd 08 06:20 PM
Testing for empty sheet Stu W Excel Programming 2 July 4th 07 09:28 PM
Copy row with an empty cell for each row in a sheet [email protected] Excel Discussion (Misc queries) 2 April 24th 07 05:18 AM
Is there a way to cut off unused cells on a sheet newbie Excel Discussion (Misc queries) 2 August 3rd 05 06:13 PM


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