Find value in one column and replace value in another
Hi Experts
I am having trouble finding a solution to my task so I am once again hoping that I might get some assistance here.
I require a VBA script to find the values listed in Column D and replace whatever is currently in Column F with the value "30-03-AM".
The sheet name is constant "COMBINATION-DLY" and the columns that the data will appear in is always the same. What changes
from day to day is the row that the data appears. It varies from day to day based on the total number of records. Also there is a chance that a value may NOT be there every day.
Sub ReplaceValues()Dim lr As LongDim rng As Rangelr = Cells(Rows.Count, 4).End(xlUp).RowActiveSheet.AutoFilterMode = 0With Range("D1:D" & lr) .AutoFilter field:=1, Criteria1:="<>" On Error Resume Next Set rng = Range("F2:F" & lr).SpecialCells(xlCellTypeVisible) If Not rng Is Nothing Then rng.Value = "30-03-AM"End WithActiveSheet.AutoFilterMode = 0End Sub
Not sure if I it was clear that there are other values in both columns. I can't do a global type find and replace. It must be where the specific value in column D (one of those listed) is found and then the replacement can be done. Column D might contains thousands of other values. I am sorry I wasn't more clear.
A
Subodh Tiwari (Neeraj)
Where are those criteria for col. D placed in the workbook, on another Sheet?
Or you want to use them as hard coded values in the code?
Can you upload a sample workbook with some dummy data to work with?
Open in new window