Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Check to see if a formula is correct

I want to do something like this
Sub Macro1()

If Range("A1") =(=B1 + B2) Then ' This is a formula
Exit Sub
Else
Range("C1").Select 'Has correct formula
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
End If

End Sub
How do I do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 376
Default Check to see if a formula is correct

Hi

Try
Sub Macro1()

If Range("A1").HasFormula Then
Exit Sub
Else
Range("C1").Copy
Range("A1").PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
End If

End Sub

Regards
Roger Govier

oldjay wrote:
I want to do something like this
Sub Macro1()

If Range("A1") =(=B1 + B2) Then ' This is a formula
Exit Sub
Else
Range("C1").Select 'Has correct formula
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
End If

End Sub
How do I do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Check to see if a formula is correct

Try

If Range("A1").Formula < "=B1+B2" Then
Range("A1").Formula = Range("C1").Formula
End If

--
Jacob


"oldjay" wrote:

I want to do something like this
Sub Macro1()

If Range("A1") =(=B1 + B2) Then ' This is a formula
Exit Sub
Else
Range("C1").Select 'Has correct formula
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
End If

End Sub
How do I do this?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Check to see if a formula is correct

Thanks

"Jacob Skaria" wrote:

Try

If Range("A1").Formula < "=B1+B2" Then
Range("A1").Formula = Range("C1").Formula
End If

--
Jacob


"oldjay" wrote:

I want to do something like this
Sub Macro1()

If Range("A1") =(=B1 + B2) Then ' This is a formula
Exit Sub
Else
Range("C1").Select 'Has correct formula
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlFormulas
End If

End Sub
How do I do this?

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
Dup check 2 columns - need it to delete correct one Chance M Excel Worksheet Functions 5 April 1st 10 10:03 PM
Need to check if the value in one cell is correct or not RobertoB Excel Programming 12 January 9th 10 09:59 PM
Check inputbox enter is in correct format Bob Phillips Excel Programming 0 January 5th 07 09:53 AM
What's the correct format to check the name of a sheet? Mikke Excel Programming 3 May 18th 06 09:20 PM
How to correct this formula and check if more issues are existing? Metallo[_3_] Excel Programming 9 October 27th 04 01:38 PM


All times are GMT +1. The time now is 09:17 AM.

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"