|
-
Jun 30th, 2004, 10:16 AM
#1
Thread Starter
New Member
Filling Excel Columns with a Condition
I am working in Excel and I have 2 columns.
for example
A B C
140000
5453 (140000)
6764 (140000)
3373 (140000)
140001
3623 (140001)
2547 (140001)
I want Excel to go through the spreadsheet and filling column A into Column C, next to the value in B. However Column A has other values in it but if I could use a condition > than 140000 to pull the numbers I want.
Parenthesis is the output I want.
Hope this is clear,
Thanks
-
Jul 1st, 2004, 04:55 AM
#2
I think I've understood that one there. This script will look at each cell value in turn in column A. If the value in this cell is less than 14000, the value copied into the corresponding column C cell will equal 14000, otherwise, if the value in cell A is greater than 14000, this value itself is copied across to the corresponding column C cell.
VB Code:
Private Sub CommandButton1_Click()
Dim lngCounter As Long
For lngCounter = 1 To ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
If (Cells(lngCounter, 1).Value < 140000) Then
Cells(lngCounter, 3).Value = 140000
Else
Cells(lngCounter, 3).Value = Cells(lngCounter, 3).Value
End If
Next lngCounter
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|