Reading multiple boxes to produce one result (shortened code)

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)


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:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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