Create Specific Text down Column Based on Specific Text in Another Column

AlwaysLearning2018

Board Regular
Joined
Nov 23, 2018
Messages
51
Hi All,

I have created the below macro that will populate a value in 1 specific cell based on 1 specific cell in a different column. My question is how do I look at the entire column for that word and populate the other word down a different column Any help would be much appreciated!


Sub Comments()


If Worksheets(1).Range("D54").Value = "Variation Margin" Then
Worksheets(1).Range("I75").Value = "Futures Margin"

End If
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
try these codes
Code:
Dim a As Integer
a = WorksheetFunction.Match("variation margin", Worksheet("sheet1").Range("D:D"), 0)
If a > 0 Then
Worksheet("sheet1").Range("I25") = "It exists in D" & a
End If
 
Upvote 0
Couple of typos in the code try
Code:
Dim a As Integer
a = WorksheetFunction.Match("variation margin", Worksheet[COLOR=#ff0000]s[/COLOR]("sheet1").Range("D:D"), 0)
If a > 0 Then
Worksheet[COLOR=#ff0000]s[/COLOR]("sheet1").Range("I25") = "It exists in D" & a
End If
 
Upvote 0
In that case, please post you entire code showing which line is causing the problem & what is the error message?
 
Upvote 0
Hi Fluff,

Example of what I am attempting to do below.

If Range("C33").Value = "Variation Margin" Then
Range("F33").Value = "Futures Margin"

I'm not sure how to change this to get the code to read all instances of the specific word in Column C to return a certain word in Column F. The above works when I refer to 1 specific cell but if I say "C2:C800" For example I get a type mismatch. Excel Criteria below. Thanks!!

TD
VDTRANSACTION UNITSPortfolioClient Memo
10/30/2018
11/2/2018Maturity1200
10/30/201811/2/2018Maturity2400
10/30/201811/2/2018Maturity3401
10/30/201811/2/2018Maturity4402
10/30/201811/2/2018Maturity5403
10/30/201811/2/2018Maturity6404
10/30/201811/2/2018Maturity7405
10/30/201811/2/2018Repo8406
10/30/201811/2/2018Repo9407
10/30/201811/2/2018Repo10408
10/30/201811/2/2018Repo11409
10/30/201811/2/2018Repo12410
10/30/201811/2/2018Repo13411
10/30/201811/2/2018Repo14412
10/30/201811/2/2018Repo15413
10/30/201811/2/2018Purchase16414
10/30/201811/2/2018Purchase17415
10/30/201811/2/2018Purchase18416
10/30/201811/2/2018Purchase19417
10/30/201811/2/2018Purchase20418
10/30/201811/2/2018Purchase21419
10/30/201811/2/2018Purchase22420
10/30/201811/2/2018Purchase23900
10/30/201811/2/2018Purchase24901
10/30/201811/2/2018Maturity25902
10/30/201811/2/2018Maturity26903
10/30/201811/2/2018Swap27904
10/30/201811/2/2018Swap28905
10/30/201811/2/2018Swap29906
10/30/201811/2/2018Purchase30907
10/30/201811/2/2018Maturity31908
10/30/201811/2/2018Variation Margin32275Futures Margin
10/30/201811/2/2018Variation Margin33280
10/30/201811/2/2018Variation Margin34818
10/30/201811/2/2018Variation Margin35500
10/30/201811/2/2018Variation Margin36335
10/30/201811/2/2018Variation Margin37158
10/30/201811/2/2018Variation Margin38157
10/30/201811/2/2018Variation Margin39165
10/30/201811/2/2018Variation Margin40917
10/30/201811/2/2018Swap Income41918
10/30/201811/2/2018Swap Income42919
10/30/201811/2/2018Variation Margin43920
10/30/201811/2/2018Variation Margin44921
10/30/201811/2/2018Variation Margin45922
10/30/201811/2/2018Variation Margin46923
10/30/201811/2/2018Variation Margin47924
10/30/201811/2/2018Purchase48925
10/30/201811/2/2018Sale49926
10/30/201811/2/2018sale50927
10/30/201811/2/2018sale51928
10/30/201811/2/2018sale52929
10/30/201811/2/2018Purchase53930
<colgroup><col width="75" style="width: 56pt; mso-width-source: userset; mso-width-alt: 2742;"> <col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;"> <col width="97" style="width: 73pt; mso-width-source: userset; mso-width-alt: 3547;"> <col width="64" style="width: 48pt;" span="2"> <col width="87" style="width: 65pt; mso-width-source: userset; mso-width-alt: 3181;"> <tbody> </tbody>
 
Upvote 0
Try
Code:
Sub AlwaysLearning2018()
   With Range("F2", Range("C" & Rows.Count).End(xlUp).Offset(, 3))
      .Value = Evaluate(Replace("If(@=""Variation Margin"",""Futures Margin"","""")", "@", .Offset(, -3).Address))
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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