Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default compare sheets (values and formulas), alert it like spellcheckers

I have 20 sheets (like templates) and ALL of them have different information
ONLY for rows 2, 3, 4 and 5. The remaining cells of these sheets have
information (formulas and/or values) that will match each other.

The main-sheet, the one with the right Formulas and Values, will be the
current sheet that I will start running this macro.

I am looking for something like a spellchecker, but in this case will be
like a €śFormulas and Values checker between similar Sheets€ť.

For example: if I am in sheet3 and run this macro, it will compare formulas
and values in each CELLS, (but not on rows 2, 3, 4 and 5), between sheet3 and
the rest of sheets.

Moreover, It will prompt me for the first occurrence that this macro find
different between sheet3 and sheet€ťn€ť cells. This prompt will let me decide
to update the cell in sheet3, sheet€ťn€ť, to Ignore the prompt or cancel the
macro.

Any idea how to implement this macro?

Thanks

Coco.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default compare sheets (values and formulas), alert it like spellcheckers

Assume the UsedRange starts in A1

Sub aa()
Dim sh As Worksheet
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
Dim rng3 As Range, rng4 As Range
Dim ans As Long, msg As String
Set sh = ActiveSheet
Set rng = sh.UsedRange
Set rng1 = sh.Range(sh.Range("A5"), rng(rng.Count))
Set rng2 = Union(rng.Rows(1), rng1)
For Each sh1 In ActiveWorkbook.Worksheets
If sh1.Name < sh.Name Then
Set rng3 = sh1.Range(rng2.Address)
For Each cell In rng3
Set rng4 = sh.Cells(cell.Row, cell.Column)
If cell.Formula < rng4.Formula Then
msg = "Base Formula: " & rng4.Formula & vbNewLine & _
sh1.Name & " Formula: " & cell.Formula & vbNewLine & _
vbNewLine & "Make the same? "
ans = MsgBox(msg, vbYesNoCancel, "Difference found")
Select Case ans
Case vbYes
cell.Formula = rng4.Formula
Case vbCancel
Exit Sub
End Select
End If
Next
End If
Next
End Sub

--
Regards,
Tom Ogilvy



"coco" wrote in message
...
I have 20 sheets (like templates) and ALL of them have different

information
ONLY for rows 2, 3, 4 and 5. The remaining cells of these sheets have
information (formulas and/or values) that will match each other.

The main-sheet, the one with the right Formulas and Values, will be the
current sheet that I will start running this macro.

I am looking for something like a spellchecker, but in this case will be
like a "Formulas and Values checker between similar Sheets".

For example: if I am in sheet3 and run this macro, it will compare

formulas
and values in each CELLS, (but not on rows 2, 3, 4 and 5), between sheet3

and
the rest of sheets.

Moreover, It will prompt me for the first occurrence that this macro find
different between sheet3 and sheet"n" cells. This prompt will let me

decide
to update the cell in sheet3, sheet"n", to Ignore the prompt or cancel

the
macro.

Any idea how to implement this macro?

Thanks

Coco.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default compare sheets (values and formulas), alert it like spellcheck

Tom,
Thank you for your response.

One more question
What about if I want to add a restriction: to EXCLUDE for the range to
search, "values or formulas" from all cells located in columns A and C.

Do I have to change the line that says?
"Set rng2 = Union(rng.Rows(1), rng1) "


Thanks

Coco

"Tom Ogilvy" wrote:

Assume the UsedRange starts in A1

Sub aa()
Dim sh As Worksheet
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
Dim rng3 As Range, rng4 As Range
Dim ans As Long, msg As String
Set sh = ActiveSheet
Set rng = sh.UsedRange
Set rng1 = sh.Range(sh.Range("A5"), rng(rng.Count))
Set rng2 = Union(rng.Rows(1), rng1)
For Each sh1 In ActiveWorkbook.Worksheets
If sh1.Name < sh.Name Then
Set rng3 = sh1.Range(rng2.Address)
For Each cell In rng3
Set rng4 = sh.Cells(cell.Row, cell.Column)
If cell.Formula < rng4.Formula Then
msg = "Base Formula: " & rng4.Formula & vbNewLine & _
sh1.Name & " Formula: " & cell.Formula & vbNewLine & _
vbNewLine & "Make the same? "
ans = MsgBox(msg, vbYesNoCancel, "Difference found")
Select Case ans
Case vbYes
cell.Formula = rng4.Formula
Case vbCancel
Exit Sub
End Select
End If
Next
End If
Next
End Sub

--
Regards,
Tom Ogilvy



"coco" wrote in message
...
I have 20 sheets (like templates) and ALL of them have different

information
ONLY for rows 2, 3, 4 and 5. The remaining cells of these sheets have
information (formulas and/or values) that will match each other.

The main-sheet, the one with the right Formulas and Values, will be the
current sheet that I will start running this macro.

I am looking for something like a spellchecker, but in this case will be
like a "Formulas and Values checker between similar Sheets".

For example: if I am in sheet3 and run this macro, it will compare

formulas
and values in each CELLS, (but not on rows 2, 3, 4 and 5), between sheet3

and
the rest of sheets.

Moreover, It will prompt me for the first occurrence that this macro find
different between sheet3 and sheet"n" cells. This prompt will let me

decide
to update the cell in sheet3, sheet"n", to Ignore the prompt or cancel

the
macro.

Any idea how to implement this macro?

Thanks

Coco.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default compare sheets (values and formulas), alert it like spellcheck

Tom,
I got it.
Updated the "union" function: adding a 3rd column, a the column B.
Thanks

Coco


"coco" wrote:

Tom,
Thank you for your response.

One more question
What about if I want to add a restriction: to EXCLUDE for the range to
search, "values or formulas" from all cells located in columns A and C.

Do I have to change the line that says?
"Set rng2 = Union(rng.Rows(1), rng1) "


Thanks

Coco

"Tom Ogilvy" wrote:

Assume the UsedRange starts in A1

Sub aa()
Dim sh As Worksheet
Dim rng As Range, rng1 As Range
Dim rng2 As Range, cell As Range
Dim rng3 As Range, rng4 As Range
Dim ans As Long, msg As String
Set sh = ActiveSheet
Set rng = sh.UsedRange
Set rng1 = sh.Range(sh.Range("A5"), rng(rng.Count))
Set rng2 = Union(rng.Rows(1), rng1)
For Each sh1 In ActiveWorkbook.Worksheets
If sh1.Name < sh.Name Then
Set rng3 = sh1.Range(rng2.Address)
For Each cell In rng3
Set rng4 = sh.Cells(cell.Row, cell.Column)
If cell.Formula < rng4.Formula Then
msg = "Base Formula: " & rng4.Formula & vbNewLine & _
sh1.Name & " Formula: " & cell.Formula & vbNewLine & _
vbNewLine & "Make the same? "
ans = MsgBox(msg, vbYesNoCancel, "Difference found")
Select Case ans
Case vbYes
cell.Formula = rng4.Formula
Case vbCancel
Exit Sub
End Select
End If
Next
End If
Next
End Sub

--
Regards,
Tom Ogilvy



"coco" wrote in message
...
I have 20 sheets (like templates) and ALL of them have different

information
ONLY for rows 2, 3, 4 and 5. The remaining cells of these sheets have
information (formulas and/or values) that will match each other.

The main-sheet, the one with the right Formulas and Values, will be the
current sheet that I will start running this macro.

I am looking for something like a spellchecker, but in this case will be
like a "Formulas and Values checker between similar Sheets".

For example: if I am in sheet3 and run this macro, it will compare

formulas
and values in each CELLS, (but not on rows 2, 3, 4 and 5), between sheet3

and
the rest of sheets.

Moreover, It will prompt me for the first occurrence that this macro find
different between sheet3 and sheet"n" cells. This prompt will let me

decide
to update the cell in sheet3, sheet"n", to Ignore the prompt or cancel

the
macro.

Any idea how to implement this macro?

Thanks

Coco.




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
Compare Sheets values in two colums Geir[_2_] Excel Worksheet Functions 1 April 7th 08 01:55 PM
create alert when in sheets are grouped Twishlist Excel Worksheet Functions 1 April 5th 07 04:50 AM
dummy alert - divide values by values Micayla Bergen Excel Discussion (Misc queries) 1 May 4th 05 02:16 AM
compare two cell values on different sheets sagarh Excel Programming 3 February 16th 04 01:42 PM


All times are GMT +1. The time now is 11:29 PM.

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"