Modify VBA code

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,340
Office Version
  1. 365
Platform
  1. Windows
I want to modify this. I no longer need it to look over 7 to see if it equals "Phantom". So I need to take that part out. Just check over 2 columns and see if its a "Y" if so change G to "FLST"
but now I need it to put the "FLST" in column F not G

THANK YOU!

Code:
Sub Find_FloorStock()
'Author: G Heyman 190221
'Update "Type" Find Floor Stock and change from B to F"

'E is the Make/Buy 2 over is the FloorStock
With Range("G5", Range("E" & Rows.Count).End(xlUp))
.Value = Evaluate(Replace("if((@=""B"")*((" & .Offset(, 7).Address & "=""Phantom"")+(" & .Offset(, 2).Address & "=""Y"")),""FLST"",@)", "@", .Address))
   End With

End Sub
 
Code:
Sub Find_FloorStock()

'E is the Make/Buy (B) 2 over in column G is the FloorStock Id (Y) Then change Com_Type in column F
With Range("F2", Range("E" & Rows.Count).End(xlUp).Offset(, 0))
      .Value = Evaluate(Replace("if((@=""B"")*((" & .Offset(, 2).Address & "=""Y"")),""FLST"",@)", "@", .Address))
'.Value = Evaluate(Replace("if((" & .Offset(, -1).Address & "=""B"")*(@=""Y""),""FLST"",@)", "@", .Address))


   End With

End Sub
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Why did you change the code?
If "B" is in col E & "Y" is in col F, with FLST to replace the "Y" in col F, the code I supplied should work.
 
Upvote 0
My bad Fluff, I just realized I gave you Bad data (Which is why your code probably didn't work)
Column E has the "B's"
Column G has the "Y's"
Column F is what I want to Change to "FLST"

If Column E = "B" and Column G = "Y" Then
Column G = "FLST"

Sorry Fluff, I changed the columns around on my spreadsheet and didn't account for that. Truly sorry to have wasted your time.
 
Upvote 0
Ok, how about
VBA Code:
Sub gheyman()
    With Range("F5", Range("E" & Rows.Count).End(xlUp).Offset(, 1))
        .Value = Evaluate(Replace("if((" & .Offset(, -1).Address & "=""B"")*(" & .Offset(, 1).Address & "=""Y""),""FLST"",@)", "@", .Address))
    End With
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub gheyman()
    With Range("F5", Range("E" & Rows.Count).End(xlUp).Offset(, 1))
        .Value = Evaluate(Replace("if((" & .Offset(, -1).Address & "=""B"")*(" & .Offset(, 1).Address & "=""Y""),""FLST"",@)", "@", .Address))
    End With
End Sub
That worked perfectly! THANK YOU!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,755
Members
448,989
Latest member
mariah3

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