View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Chris Bode via OfficeKB.com Chris Bode via OfficeKB.com is offline
external usenet poster
 
Posts: 47
Default Need a help of preparing excel macro

You can do this using a macro
Please follow following steps
1.Right Click toolbarclick control box
2.From control box select a command button and draw it to your sheet
3.Double click the command button to open code window and paste following
codes
Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 2
col = 2

Dim amt1 As Double, amt2 As Double
amt1 = 0
amt2 = 0

While Sheet1.Cells(row, col).Value < ""

If Sheet1.Cells(row, col).Value = Sheet1.Cells(row - 1, col).Value
Then
amt1 = CDbl(Trim(Sheet1.Cells(row, col + 2).Value))
amt2 = CDbl(Trim(Sheet1.Cells(row - 1, col + 2).Value))

If Abs(amt1 + amt2) <= 10 Then

Sheet1.Cells(row, col + 3).Value = "C"
Sheet1.Cells(row - 1, col + 3).Value = "C"

End If

End If

row = row + 1
Wend
End Sub

Now you will get the result on clicking the command button

Hope this one works for you

Have a nice time€¦.

Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com

--
Message posted via http://www.officekb.com