Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA Code to check formulas in a range

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to search
for the answer myself, however, I am hoping one of you gurus can give me a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1). This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default VBA Code to check formulas in a range

Make sure that D1 reads =SUM(A1:C1). Hover the mouse over the bottom right
corner of the cell (D1) so that it becomes a black cross. Click and drag down
to the bottom of your data. This will put the correct formula in each cell.

Hope this is what you were after
Rowan

"FrigidDigit" wrote:

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to search
for the answer myself, however, I am hoping one of you gurus can give me a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1). This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VBA Code to check formulas in a range

One way:

Instead of checking each formula, it's probably just as easy to re-enter
the formulae:

With Sheets("Sheet1")
.Cells(1, 4).Resize(.Cells(.Rows.Count, _
1).End(xlUp).Row).Formula = "=SUM(A1:C1)"
End With


In article ,
"FrigidDigit" wrote:

I have a looming deadline for this spreadsheet else I'd try harder to search
for the answer myself, however, I am hoping one of you gurus can give me a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1). This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each cell,
taking into account the row offset change?

Thanks for any advice!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default VBA Code to check formulas in a range

If you just want to check each cell via VBA then something like

Sub chk()
Dim eRow As Long
Dim myRange As Range
Dim cell As Range

eRow = Cells(Rows.Count, 3).End(xlUp).Row
Set myRange = Range(Cells(1, 4), Cells(eRow, 4))
For Each cell In myRange
If cell.FormulaR1C1 < "=SUM(RC[-3]:RC[-1])" Then
MsgBox "Error in cell " & cell.Address
End If
Next cell

End Sub

Regards
Rowan

"FrigidDigit" wrote:

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to search
for the answer myself, however, I am hoping one of you gurus can give me a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1). This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA Code to check formulas in a range

Thanks Rowan, but I was looking for VBA code to do this.
Ciao!

"Rowan" wrote in message
...
Make sure that D1 reads =SUM(A1:C1). Hover the mouse over the bottom right
corner of the cell (D1) so that it becomes a black cross. Click and drag
down
to the bottom of your data. This will put the correct formula in each
cell.

Hope this is what you were after
Rowan

"FrigidDigit" wrote:

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to
search
for the answer myself, however, I am hoping one of you gurus can give me
a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a
user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1).
This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each
cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA Code to check formulas in a range

Thanks, but I need to point out to the endusers which formulas they
overwrite (if any). Your code will certainly come in handy for other
projects tho!
FD

"JE McGimpsey" wrote in message
...
One way:

Instead of checking each formula, it's probably just as easy to re-enter
the formulae:

With Sheets("Sheet1")
.Cells(1, 4).Resize(.Cells(.Rows.Count, _
1).End(xlUp).Row).Formula = "=SUM(A1:C1)"
End With


In article ,
"FrigidDigit" wrote:

I have a looming deadline for this spreadsheet else I'd try harder to
search
for the answer myself, however, I am hoping one of you gurus can give me
a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a
user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1).
This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each
cell,
taking into account the row offset change?

Thanks for any advice!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA Code to check formulas in a range

Thanks Rowan!
Exactly what I was looking for!

FD

"Rowan" wrote in message
...
If you just want to check each cell via VBA then something like

Sub chk()
Dim eRow As Long
Dim myRange As Range
Dim cell As Range

eRow = Cells(Rows.Count, 3).End(xlUp).Row
Set myRange = Range(Cells(1, 4), Cells(eRow, 4))
For Each cell In myRange
If cell.FormulaR1C1 < "=SUM(RC[-3]:RC[-1])" Then
MsgBox "Error in cell " & cell.Address
End If
Next cell

End Sub

Regards
Rowan

"FrigidDigit" wrote:

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to
search
for the answer myself, however, I am hoping one of you gurus can give me
a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a
user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1).
This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each
cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default VBA Code to check formulas in a range

Just another question:
If I need to use cell references (not R1C1) can I still do something
similar?
Then I could use this with some of my more complicated formulas?

Thanks

FD


"FrigidDigit" wrote in message
...
Thanks Rowan!
Exactly what I was looking for!

FD

"Rowan" wrote in message
...
If you just want to check each cell via VBA then something like

Sub chk()
Dim eRow As Long
Dim myRange As Range
Dim cell As Range

eRow = Cells(Rows.Count, 3).End(xlUp).Row
Set myRange = Range(Cells(1, 4), Cells(eRow, 4))
For Each cell In myRange
If cell.FormulaR1C1 < "=SUM(RC[-3]:RC[-1])" Then
MsgBox "Error in cell " & cell.Address
End If
Next cell

End Sub

Regards
Rowan

"FrigidDigit" wrote:

Hi All,

I have a looming deadline for this spreadsheet else I'd try harder to
search
for the answer myself, however, I am hoping one of you gurus can give me
a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a
user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1).
This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each
cell,
taking into account the row offset change?

Thanks for any advice!

Frigid Digit








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default VBA Code to check formulas in a range

Why not lock those cells and protect the sheet?

"FrigidDigit" wrote:

Thanks, but I need to point out to the endusers which formulas they
overwrite (if any). Your code will certainly come in handy for other
projects tho!
FD

"JE McGimpsey" wrote in message
...
One way:

Instead of checking each formula, it's probably just as easy to re-enter
the formulae:

With Sheets("Sheet1")
.Cells(1, 4).Resize(.Cells(.Rows.Count, _
1).End(xlUp).Row).Formula = "=SUM(A1:C1)"
End With


In article ,
"FrigidDigit" wrote:

I have a looming deadline for this spreadsheet else I'd try harder to
search
for the answer myself, however, I am hoping one of you gurus can give me
a
quick answer:

I wish to check that the formulae in a sheet have not been changed by a
user
and that each cell contains the correct formula.

I have values in columns A:C and in D I have the formula =Sum(A1:C1).
This
continues down for about 250 rows.

How can I check down the D column that the formula is correct in each
cell,
taking into account the row offset change?

Thanks for any advice!




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
Just a code check please... ste mac Excel Programming 9 March 21st 05 09:29 AM
Name Check Box in code Paul Excel Programming 4 December 5th 04 03:09 PM
Please check my code? Rich[_25_] Excel Programming 2 October 27th 04 07:12 AM
Please help (need a code check) Aaron Cooper Excel Programming 5 April 9th 04 05:56 PM
Check Box Code Bob Excel Programming 3 January 14th 04 06:07 AM


All times are GMT +1. The time now is 01:06 AM.

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"