Find and Replace values within a single column

Rudy

New Member
Joined
Jan 3, 2008
Messages
8
I am trying to find/create code that will allow me to find and replace any value within a column, that will always be named "Taxable Amount" as the header but may not always be in the same column (i.e. needs to be dynamic because it may in one instance be "C1" and the next be "H1"). I want the code to be able to go down the colomn row by row and replace any value that is less than zero ("<0") with "0".

This would be code that would be placed within my current code that is used to copy information from one place and paste into the new sheet, but I cant seem to get it to work.

Any help would be great.

This is what I have been playing around with to start, but is obviously incorrect because I keep getting an error:
Code:
Dim WageCol
Set WageCol = Range(ActiveSheet.Find("Taxable Wages").End(xlDown))

'When WageCol is <0      need help with
'Then .Value = "0"      need help with
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
This will replace a numbers less than zero with the number zero just in the column with your Text:
Code:
Sub FindReplaceTest()
Dim Rng As Range
Dim c As Range
    ColNum = Cells.Find(What:="Taxable Amount").Column
    LastRow = Cells(Rows.Count, ColNum).End(xlUp).Row
    Set Rng = Range(Cells(1, ColNum), Cells(LastRow, ColNum))
    For Each c In Rng
        If c.Value < 0 Then
           c.Value = 0
        End If
    Next c
End Sub
 
Last edited:
Upvote 0
Never mind, I had spelled "Taxable Amount" as "Taxable Amt", so I made the change and it works just fine.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top