Home If a value in one field is x then make a value in another field y using VBA
Reply: 0

If a value in one field is x then make a value in another field y using VBA

user9014
1#
user9014 Published in September 19, 2018, 6:54 pm

I currently have a spreadsheet that has a number of borrowers. I wish for if the number of borrowers in column V is more than 1 for it to return a value of NA in column HD and if it is just one borrower for it to return a value of ND.

I currently have the following but could somebody please advise how I get this to start from the fifth row down and if there is a faster way as there are tens of thousands of fields and it is doing each one manually.

Sub Change()

Dim lngLoop As Long

lngLoop = 1

For lngLoop = 1 To Rows.Count

If Cells(lngLoop, 22).Value = "1" Then Cells(lngLoop, 212).Value = "NA"

If Cells(lngLoop, 22).Value > 1 Then Cells(lngLoop, 212).Value = "ND"

Next lngLoop End Sub

share|improve this question
  • 4
    I think you've answered your own question "a simple if statement" I doubt you'll get anyone to write it for you. – Nathan_Sav Aug 17 '16 at 11:17
  • 1
    Start by showing what you tried. People are more inclined to help you correct your mistakes, than do your (simple) job for you. It's actually how stackoverflow works. – CyberClaw Aug 17 '16 at 11:19
  • You don't even need VBA for this...a simple Formula will do – DragonSamu Aug 17 '16 at 12:27
  • It is automated data that is already part of a bigger macro, having a formula would not work as the amount of cells changes on a monthly basis. – JDRows Aug 17 '16 at 12:31
  • Range("HD5").Select ActiveCell.FormulaR1C1 = "=IF(RC[-190]>1,""ND"",""NA"")" Range("HD5").Select Selection.Copy Range(Selection, Selection.End(xlDown)).Select Application.CutCopyMode = False Selection.FillDown – JDRows Aug 17 '16 at 12:46

1 Answer 1

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.290414 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO