ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Synax for two IF conditions in VBA (https://www.excelbanter.com/excel-programming/275213-synax-two-if-conditions-vba.html)

Steven Rosenberg[_2_]

Synax for two IF conditions in VBA
 
The expression
=if(D2=D1,C1,"")

fills in the contents of cell C2, with the value if C1.
WHAT is the syntax in VBA for filling-in C2 with C1's
value IF D2-D1, AND E2=E1?

Thanks!

Steven Rosenberg

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Chip Pearson

Synax for two IF conditions in VBA
 
Steven,

Try something like

If (Range("D1").Value = Range("D2").Value) And _
(Range("E1").Value = Range("E2").Value) Then
Range("C2").Value = Range("C1").Value
Else
' do nothing
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Steven Rosenberg" wrote in message
...
The expression
=if(D2=D1,C1,"")

fills in the contents of cell C2, with the value if C1.
WHAT is the syntax in VBA for filling-in C2 with C1's
value IF D2-D1, AND E2=E1?

Thanks!

Steven Rosenberg

*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Alan Beban[_3_]

Synax for two IF conditions in VBA
 
Chip Pearson provided a VBA programming solution because you posted in
the . . . programming newsgroup. Did you want

=IF(AND(D1=D2,E1=E2),C1,"")

If so, a similar question in the future might best be posted to the
....worksheet.functions newsgroup.

Alan
Beban

Steven Rosenberg wrote:
The expression
=if(D2=D1,C1,"")

fills in the contents of cell C2, with the value if C1.
WHAT is the syntax in VBA for filling-in C2 with C1's
value IF D2-D1, AND E2=E1?

Thanks!

Steven Rosenberg

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Steven Rosenberg[_2_]

Synax for two IF conditions in VBA
 


Thanks for your help. The first proposal looks more like a macro than
formula; I'll try it, since that was my original hope, several weeks
ago.

The Worksheet function group? A URL?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Steven Rosenberg[_2_]

Synax for two IF conditions in VBA
 
Mr. Pearson:

Thanks your your answer. But how do I make that code
work all the way down a column?

Steven Rosenberg

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 08:31 PM.

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