Guest User

Untitled

a guest
Mar 14th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Option Explicit
  2. Public Sub CheckCIF()
  3. Dim fileArray
  4. Dim finalRow As Long
  5. Dim targetColumn As Long
  6. Dim lastColumn As Long
  7.  
  8. With Worksheets("Loan Data")
  9.  
  10. finalRow = .Range("A" & Rows.Count).End(xlUp).Row
  11. lastColumn = .Cells(1, .Columns.Count).End(xlToLeft).Column
  12.  
  13. Dim targetRange As Range
  14. Dim searchRange As Range
  15.  
  16. Set searchRange = .Range(.Cells(1, 1), .Cells(1, lastColumn))
  17. Set targetRange = searchRange.Find("CIF #")
  18.  
  19. If targetRange Is Nothing Then
  20. Debug.Print "Column not found"
  21. Exit Sub
  22. End If
  23.  
  24. targetColumn = targetRange.Column
  25. fileArray = .Range(.Cells(2, "A"), .Cells(finalRow, targetColumn)).Value
  26.  
  27. Dim rowCounter As Long
  28. For rowCounter = 1 To finalRow - 1
  29. If fileArray(rowCounter, 2) = vbNullString And fileArray(rowCounter, 1) <> vbNullString Then
  30. .Range("CIF_" & rowCounter) = InputBox("Please enter the CIF Number for " & vbCrLf & fileArray(rowCounter, 1))
  31. End If
  32. Next
  33. End With
  34.  
  35. End Sub
Advertisement
Add Comment
Please, Sign In to add comment