ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   count of changed data (https://www.excelbanter.com/excel-programming/389341-count-changed-data.html)

ton de w

count of changed data
 
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


merjet

count of changed data
 
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



joel

count of changed data
 


"ton de w" wrote:

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

TIA

Ton




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

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