Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add condition to macro?

Status
Not open for further replies.

bren1519

Technical User
Jun 30, 2008
7
CA
Hi,
I am very new to macros and have taught myself over the last week to write the macros necessary to create a report. We are using SPSS Report Writer software but I have been told that the macro language used is ReportSmith.

I have the following macro that works except I would like to add the condition that the result must be greater than 1 otherwise derived field should = 0

Sub TotalAssets07()

a=val(SumField$("Field16","",3,0))
b=val(Field("StBalTotalAssets07"))
d=val(field("Field10"))
c=(a+b+d)/1000
derivedfield str$(c)
End Sub

Thanks for any help!
Brenda
 
Should work with addition of If/Then as below. If c > 1 it will be untouched.

Sub TotalAssets07()

a=val(SumField$("Field16","",3,0))
b=val(Field("StBalTotalAssets07"))
d=val(field("Field10"))
c=(a+b+d)/1000

IF C <= 1 THEN
C = 0
END IF

derivedfield str$(c)
End Sub

Hope that helps.



Joel Ray
Ronile, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top