ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   need a macro to drop excel sheets that were not populated (https://www.excelbanter.com/excel-programming/422171-need-macro-drop-excel-sheets-were-not-populated.html)

James

need a macro to drop excel sheets that were not populated
 
I need a macro to export only the first sheet of a workbook and the sheet
that was populated. ie: first sheet always in use with hyperlinks to other
sheets. once a hyperlinked sheet is chosen and populated I need a button
called export to only save the first sheet and the sheet populated dropping
off all the other sheets not used with the outcome of a new workbook to save
and e-mail. Any help would be greatful. Thank you

Don Guillett

need a macro to drop excel sheets that were not populated
 
Try this
Sub idsheets()
Application.DisplayAlerts = False
For i = Sheets.Count To 2 Step -1
If Sheets(i).UsedRange.Cells(1, 1) = "" Then
Sheets(i).Delete
End If
Next i
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"James" wrote in message
...
I need a macro to export only the first sheet of a workbook and the sheet
that was populated. ie: first sheet always in use with hyperlinks to other
sheets. once a hyperlinked sheet is chosen and populated I need a button
called export to only save the first sheet and the sheet populated
dropping
off all the other sheets not used with the outcome of a new workbook to
save
and e-mail. Any help would be greatful. Thank you



James

need a macro to drop excel sheets that were not populated
 

This works great, I have one problem. I can use this in a new workbook with
unnamed sheets. but when I put it into our template with named sheets I loose
all the sheets but the first one. The other sheets already have questions to
answer so they are pre-populated. Do i need to protect cells that have user
notes in them first.

"Don Guillett" wrote:

Try this
Sub idsheets()
Application.DisplayAlerts = False
For i = Sheets.Count To 2 Step -1
If Sheets(i).UsedRange.Cells(1, 1) = "" Then
Sheets(i).Delete
End If
Next i
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"James" wrote in message
...
I need a macro to export only the first sheet of a workbook and the sheet
that was populated. ie: first sheet always in use with hyperlinks to other
sheets. once a hyperlinked sheet is chosen and populated I need a button
called export to only save the first sheet and the sheet populated
dropping
off all the other sheets not used with the outcome of a new workbook to
save
and e-mail. Any help would be greatful. Thank you




Don Guillett

need a macro to drop excel sheets that were not populated
 

You didn't say so!!! Always nice to fully state your problem in the first
post.
Perhaps you could delete sheets that don't have something in a PARTICULAR
cell.

If Sheets(i).Cells(1, 1) = "" Then

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"James" wrote in message
...

This works great, I have one problem. I can use this in a new workbook
with
unnamed sheets. but when I put it into our template with named sheets I
loose
all the sheets but the first one. The other sheets already have questions
to
answer so they are pre-populated. Do i need to protect cells that have
user
notes in them first.

"Don Guillett" wrote:

Try this
Sub idsheets()
Application.DisplayAlerts = False
For i = Sheets.Count To 2 Step -1
If Sheets(i).UsedRange.Cells(1, 1) = "" Then
Sheets(i).Delete
End If
Next i
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"James" wrote in message
...
I need a macro to export only the first sheet of a workbook and the
sheet
that was populated. ie: first sheet always in use with hyperlinks to
other
sheets. once a hyperlinked sheet is chosen and populated I need a
button
called export to only save the first sheet and the sheet populated
dropping
off all the other sheets not used with the outcome of a new workbook to
save
and e-mail. Any help would be greatful. Thank you






All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com