View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chris Bode via OfficeKB.com Chris Bode via OfficeKB.com is offline
external usenet poster
 
Posts: 47
Default Copy corresponding cell if value is 0

1.Right click on toolbarselect control box
2.from the control box that appears on the sheet1, select and draw a command
button on your sheet
3.Double click the command button to open the code window and paste following
codes
#
Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 5

Dim rowinsheet2 As Integer, colinsheet2 As Integer
rowinsheet2 = 1
colinsheet2 = 5
While Sheet1.Cells(row, col).Value < ""
If CInt(Sheet1.Cells(row, col).Value) 0 Then
Sheet2.Cells(rowinsheet2, colinsheet2).Value = Sheet1.Cells(row,
col).Value
Sheet2.Cells(rowinsheet2, colinsheet2 - 1).Value = Sheet1.Cells
(row, col - 1).Value
rowinsheet2 = rowinsheet2 + 1
End If
row = row + 1
Wend
End Sub
#

Note that it will move data from sheet1 to sheet2


Hope this works


Have a nice time

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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200902/1