bsw2112
Jul 30th, 2003, 02:18 PM
Hello,
I am very new to spreadsheets...
I was wondering if anyone can help me with writing a macro
that would replace cell values in a column based a values in certain cells in that column.
//i would like to replace the values of cells that have the value 0 in them with the value of a variable.
<pseudocode>
Sub ChangeAll()
dim intValueOfCell
Range("A1").Select
intValueOfCell= ActiveCell.Value
Do While ActiveCell.Value <> "" 'cell is empty
If ActiveCell.Value = 0 Then
ActiveCell.Value = intValueOfCell
Else
intValueOfCell = ActiveCell.Value
End If
'select next cell in column (don't know what is the code for that
' maybe ****************
Selection.Offset(0,1).Select
'**********************
Loop
Range("A1").Select
End Sub
</pseudocode>
example of a column
***column 1***
12
0
0
0
17
0
0
89
0
0
0
0
102
0
0
160
etc...
************
I would do this manualy but there are over 8000 records (cells)
with values in them
Please help
bsw
I am very new to spreadsheets...
I was wondering if anyone can help me with writing a macro
that would replace cell values in a column based a values in certain cells in that column.
//i would like to replace the values of cells that have the value 0 in them with the value of a variable.
<pseudocode>
Sub ChangeAll()
dim intValueOfCell
Range("A1").Select
intValueOfCell= ActiveCell.Value
Do While ActiveCell.Value <> "" 'cell is empty
If ActiveCell.Value = 0 Then
ActiveCell.Value = intValueOfCell
Else
intValueOfCell = ActiveCell.Value
End If
'select next cell in column (don't know what is the code for that
' maybe ****************
Selection.Offset(0,1).Select
'**********************
Loop
Range("A1").Select
End Sub
</pseudocode>
example of a column
***column 1***
12
0
0
0
17
0
0
89
0
0
0
0
102
0
0
160
etc...
************
I would do this manualy but there are over 8000 records (cells)
with values in them
Please help
bsw