count of changed data

T

ton de w

Hello,
I am using a macro to lower case selected areas.
How can I correctly print the number of cells changed, rather than
visited?

Sub lowerme()
Dim cell As Object
Dim count As Integer
count = 0
For Each cell In Selection
count = count + 1
cell.Value = LCase(cell.Value)
Next cell
MsgBox count & " Cells Changed "
End Sub

TIA

Ton
 
M

merjet

This worked for me:
If cell.Value <> LCase(cell.Value) Then count = count + 1

Of course, you need this before you change a cell.

Hth,
Merjet
 
G

Guest

ton de w said:
Hello,
I am using a macro to lower case selected areas.
How can I correctly print the number of cells changed, rather than
visited?
Sub lowerme()
Dim cell As Object
Dim count As Integer
count = 0
changed = 0
For Each cell In Selection
oldvalue = cell.Value
count = count + 1
cell.Value = LCase(cell.Value)
if oldvalue <> cell.value then
changed = changed + 1
end if
Next cell
MsgBox count & Changed
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top