JohnHarmeston
New Member
- Joined
- Apr 17, 2019
- Messages
- 7
Hey,
I'm currently struggling trying to get this code working so I was hoping for a helping hand please?
the situation is:
I have varying products that produce the owner's name as the outcome depending on circumstance. Initially I had it working fine from reading one column of info, but hit a wall when I had to make the overall owner determined reading multiple products.
The spreadsheet is set up so that it shows from 1 to 10 columns that I paste info in for on another page, depending on how many products there are; with the columns after 1 clearing to read nothing should they not be needed. the 1 column works fine but I'm unable to get it to read the 2nd column onwards that could potentially change the owner.
I'll post the current state of the code below; but have a feeling I've made it unnecessarily complicated. (I've defaulted names / situations for privacy reasons.) I've tried to shorten the code as much I can but after implimenting the dim/for to name variables (First time using!), it's now saying 'mismatch error' before I've gotten a chance to test it.
Can someone let me know
a) what I've currently done to mess this up
b) From what's stated above, if there's an easier way to type this code than I've attempted.
Thanks for your time!
i = the columns
data = the overall selected boxes (28 being the row)
I'm currently struggling trying to get this code working so I was hoping for a helping hand please?
the situation is:
I have varying products that produce the owner's name as the outcome depending on circumstance. Initially I had it working fine from reading one column of info, but hit a wall when I had to make the overall owner determined reading multiple products.
The spreadsheet is set up so that it shows from 1 to 10 columns that I paste info in for on another page, depending on how many products there are; with the columns after 1 clearing to read nothing should they not be needed. the 1 column works fine but I'm unable to get it to read the 2nd column onwards that could potentially change the owner.
I'll post the current state of the code below; but have a feeling I've made it unnecessarily complicated. (I've defaulted names / situations for privacy reasons.) I've tried to shorten the code as much I can but after implimenting the dim/for to name variables (First time using!), it's now saying 'mismatch error' before I've gotten a chance to test it.
Can someone let me know
a) what I've currently done to mess this up
b) From what's stated above, if there's an easier way to type this code than I've attempted.
Thanks for your time!
i = the columns
data = the overall selected boxes (28 being the row)
Code:
Sub OwnerPull()
Dim i As String, data As String
For i = "b" To "k"
data = Sheet2.Range(i & 24).Value
If Range("Formulae!B39").Value = "Situation1" And Range("Formulae!B14").Value = "Situation4" Then
Range("Formulae!B24").Value = "name1"
ElseIf Range("Formulae!B39").Value = "Situation1" And Range("Formulae!B14").Value = "Situation5" Then
Range("Formulae!B24").Value = "name2"
ElseIf Range("Formulae!B39").Value = "Situation1" And Range("Formulae!B55").Value > #1/13/2005# Then
Range("Formulae!B24").Value = "name1"
ElseIf Range("Formulae!B39").Value = "Situation1" And Range("Formulae!B55").Value < #1/14/2005# Then
Range("Formulae!B24").Value = "name2"
ElseIf Range("Formulae!B14").Value = "Situation2" Then
Range("Formulae!B24").Value = "name3"
ElseIf Range("Formulae!B14").Value = "Situation3" Then
Range("Formulae!B24").Value = "name4"
ElseIf Range("Formulae!B14").Value = "Situation4" And Range("'ID&V (Stub)'!B18").Value <> "Yes" Then
Range("Formulae!B24").Value = "name5"
ElseIf Range("Formulae!B14").Value = "Situation4" And Range("'ID&V (Stub)'!B18").Value = "Yes" Then
Range("Formulae!B24").Value = "name6"
ElseIf Range("Formulae!B14").Value = "Situation5" And Range("Formulae!B15").Value = "Fast Track" Then
Range("Formulae!B24").Value = "name7"
ElseIf data = "N/A" Or data = "" Then
Range("Formulae!B24").Value = "name8"
Else
Range("Formulae!B24").Value = "name9"
End If
Last edited: