carcharoth2554
New Member
- Joined
- Feb 5, 2013
- Messages
- 30
Hi guys,
Running Win 7 64 with Xl 2010, still getting into the flow of the code here.
I have working code here but it is sloppy....any suggestions on cleaning it up? I know I should be building in a loop to run through the cell references but my brain just cant quite get there!
Thanks!
Dim result As String
Dim resourceSheet As Worksheet
Dim resourceDest As Worksheet
Dim initialsArray(1 To 5) As String
If resourceDest.Range("E8") <> "" Then initialsArray(1) = Application.WorksheetFunction.VLookup(resourceDest.Range("E8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("F8") <> "" Then initialsArray(2) = Application.WorksheetFunction.VLookup(resourceDest.Range("F8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("G8") <> "" Then initialsArray(3) = Application.WorksheetFunction.VLookup(resourceDest.Range("G8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("H8") <> "" Then initialsArray(4) = Application.WorksheetFunction.VLookup(resourceDest.Range("H8"), resourceSheet.Range("G7:H17"), 2, False) & ", "
If resourceDest.Range("I8") <> "" Then initialsArray(5) = Application.WorksheetFunction.VLookup(resourceDest.Range("I8"), resourceSheet.Range("G7:H17"), 2, False)
result = initialsArray(1) & initialsArray(2) & initialsArray(3) & initialsArray(4) & initialsArray(5)
.Cells(loopVertCount, 5) = result
Running Win 7 64 with Xl 2010, still getting into the flow of the code here.
I have working code here but it is sloppy....any suggestions on cleaning it up? I know I should be building in a loop to run through the cell references but my brain just cant quite get there!
Thanks!
Dim result As String
Dim resourceSheet As Worksheet
Dim resourceDest As Worksheet
Dim initialsArray(1 To 5) As String
If resourceDest.Range("E8") <> "" Then initialsArray(1) = Application.WorksheetFunction.VLookup(resourceDest.Range("E8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("F8") <> "" Then initialsArray(2) = Application.WorksheetFunction.VLookup(resourceDest.Range("F8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("G8") <> "" Then initialsArray(3) = Application.WorksheetFunction.VLookup(resourceDest.Range("G8"), resourceSheet.Range("A7:B26"), 2, False) & ", "
If resourceDest.Range("H8") <> "" Then initialsArray(4) = Application.WorksheetFunction.VLookup(resourceDest.Range("H8"), resourceSheet.Range("G7:H17"), 2, False) & ", "
If resourceDest.Range("I8") <> "" Then initialsArray(5) = Application.WorksheetFunction.VLookup(resourceDest.Range("I8"), resourceSheet.Range("G7:H17"), 2, False)
result = initialsArray(1) & initialsArray(2) & initialsArray(3) & initialsArray(4) & initialsArray(5)
.Cells(loopVertCount, 5) = result