lundi 3 août 2015

Combination of If Then and Do Loop (I think)

This is probably an easy question for someone who is familiar with VBA, but as a newbie, I am totally coming up empty.

I've got two sheets, one is the raw data that I am already using code to pull from Project with no issues. The other is the output sheet. On the Sheet with the data, I've got 3 columns (A, E, and H). Column A has a list of tasks, column E has a description, and column H has a Fiscal Year and Quarter.

On the output page, I have 10 years worth of fiscal years.

What I'm looking to do is scan the tasks for a certain type of task, then once I find that task, I output the description information in the correct corresponding fiscal year.

I feel like it will need to be a combination of a DO Loop and an If Then, but what I was trying was not working. Below is what I started with and knew pretty quickly that it wouldn't work.

Do Until Worksheets("Project Data").Range("A1").Offset(row, 0).Value = Empty

If Worksheets("Project Data").Range("A1").Value = "Task example*" Then
    If Worksheets("Project Data").Range("H1") = "FY15*" Then
        If Worksheets("Project Data").Range("E1") = "" Then Worksheets("Output").Range("C5") = 1
            ElseIf Worksheets("Project Data").Range("E1") = "description 1*" Then Worksheets("Output").Range("C5") = 2
            ElseIf Worksheets("Project Data").Range("E1") = "description 2*" Then Worksheets("Output").Range("C5") = 3
        End If
    If Worksheets("Project Data").Range("H1") = "FY16*" Then
        If Worksheets("Project Data").Range("E1") = "" Then Worksheets("Output").Range("C6") = 1
            ElseIf Worksheets("Project Data").Range("E1") = "description 1*" Then Worksheets("Output").Range("C6") = 2
            ElseIf Worksheets("Project Data").Range("E1") = "description 2*" Then Worksheets("Output").Range("C6") = 3
        End If

Loop

As I said, this was not working for multiple reasons. Any help would be greatly appreciated! Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire