Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
SJC
 
Posts: n/a
Default Clear Contents Macro

I have a workbook which contains one spreadsheet for each month of the
calendar year. The user enters data by rows into the first spreadsheet
month. This data is then linked to the next spreadsheet or calendar month.
The user would then go into the next month and edit the data at a later date.
Since new data is added into rows each month, I have a macro which sorts the
data alphabetically. When a cell is left blank however, a zero is carried
over into the next spreadsheet. Then when the user selects the button to
alphabetize the data rows, all of the rows with zeros rise to the top, and
the rows with text go to the bottom, in alphabetical order, of course. I
figured out how to make the zeros go away in the tools menu, but the text
rows continue to go to the bottom.

Is there a way to write a macro to clear the contents of any cells with a
zero in it and then alphabetize? Any other options?

Thanks for any suggestions.
  #2   Report Post  
Bruno Campanini
 
Posts: n/a
Default Clear Contents Macro

"SJC" wrote in message
...
I have a workbook which contains one spreadsheet for each month of the
calendar year. The user enters data by rows into the first spreadsheet
month. This data is then linked to the next spreadsheet or calendar
month.
The user would then go into the next month and edit the data at a later
date.
Since new data is added into rows each month, I have a macro which sorts
the
data alphabetically. When a cell is left blank however, a zero is carried
over into the next spreadsheet. Then when the user selects the button to
alphabetize the data rows, all of the rows with zeros rise to the top, and
the rows with text go to the bottom, in alphabetical order, of course. I
figured out how to make the zeros go away in the tools menu, but the text
rows continue to go to the bottom.

Is there a way to write a macro to clear the contents of any cells with a
zero in it and then alphabetize? Any other options?


=======================
Sub Button53_Click()
Dim i

For Each i In [H281:H292]
If i.Value = 0 Then
i.Value = ""
End If
Next

[H281:H292].Sort Key1:=[H281], Order1:=xlAscending

End Sub
====================

Replace [H281:H292] with your data range.
Ciao
Bruno


  #3   Report Post  
SJC
 
Posts: n/a
Default Clear Contents Macro

Thank you--the macro does remove all of the zeros, but it does not sort the
data. Any suggestions?

"Bruno Campanini" wrote:

"SJC" wrote in message
...
I have a workbook which contains one spreadsheet for each month of the
calendar year. The user enters data by rows into the first spreadsheet
month. This data is then linked to the next spreadsheet or calendar
month.
The user would then go into the next month and edit the data at a later
date.
Since new data is added into rows each month, I have a macro which sorts
the
data alphabetically. When a cell is left blank however, a zero is carried
over into the next spreadsheet. Then when the user selects the button to
alphabetize the data rows, all of the rows with zeros rise to the top, and
the rows with text go to the bottom, in alphabetical order, of course. I
figured out how to make the zeros go away in the tools menu, but the text
rows continue to go to the bottom.

Is there a way to write a macro to clear the contents of any cells with a
zero in it and then alphabetize? Any other options?


=======================
Sub Button53_Click()
Dim i

For Each i In [H281:H292]
If i.Value = 0 Then
i.Value = ""
End If
Next

[H281:H292].Sort Key1:=[H281], Order1:=xlAscending

End Sub
====================

Replace [H281:H292] with your data range.
Ciao
Bruno



  #4   Report Post  
SJC
 
Posts: n/a
Default Clear Contents Macro

Please forget my last post. I figured it out--thanks for all of your help.

"SJC" wrote:

Thank you--the macro does remove all of the zeros, but it does not sort the
data. Any suggestions?

"Bruno Campanini" wrote:

"SJC" wrote in message
...
I have a workbook which contains one spreadsheet for each month of the
calendar year. The user enters data by rows into the first spreadsheet
month. This data is then linked to the next spreadsheet or calendar
month.
The user would then go into the next month and edit the data at a later
date.
Since new data is added into rows each month, I have a macro which sorts
the
data alphabetically. When a cell is left blank however, a zero is carried
over into the next spreadsheet. Then when the user selects the button to
alphabetize the data rows, all of the rows with zeros rise to the top, and
the rows with text go to the bottom, in alphabetical order, of course. I
figured out how to make the zeros go away in the tools menu, but the text
rows continue to go to the bottom.

Is there a way to write a macro to clear the contents of any cells with a
zero in it and then alphabetize? Any other options?


=======================
Sub Button53_Click()
Dim i

For Each i In [H281:H292]
If i.Value = 0 Then
i.Value = ""
End If
Next

[H281:H292].Sort Key1:=[H281], Order1:=xlAscending

End Sub
====================

Replace [H281:H292] with your data range.
Ciao
Bruno



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
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Using a Macro to clear out check box seletions Mel Excel Worksheet Functions 5 May 20th 05 08:35 PM
Clear Contents - NonBold cells Steve Excel Discussion (Misc queries) 3 February 13th 05 11:36 PM
Clear Contents But Not Formula Gancom3 Excel Discussion (Misc queries) 2 February 1st 05 11:30 PM


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