Results 1 to 1 of 1

Thread: Reading multiple boxes to produce one result (shortened code)
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Reading multiple boxes to produce one result (shortened code)

    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 by JohnHarmeston; Apr 25th, 2019 at 11:50 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •