I have a list of tasks in a master table that I split out by function (AP, AR, purchasing, etc.). I have columns set up for each function, which I then tickmark with a "1" indicating that the task in that row corresponds to that function
I have a script that takes a specific function (say, purchasing) and places it in a separate worksheet. It copies specific information from about each task to the co-responding worksheet.
Everything except for the "% Complete" works fine, every time. The "% Complete", however, gives me different numbers depending on how I sort the master table (ex, ascending vs descending, based on date, ID #, etc.). In other words, task "A" might show as 100% complete if the master table is sorted ascending by date, but 0% complete if sorted descending by date--even though everything else about the task (the name, dates, description, etc.) all get copied correctly. I'm at a loss as to why that is.
Here's a snippit of the code:
Sub PURTasks()
Set m = Sheets("Master Project Plan") 'Worksheet that contains Master Task List
Set t = Sheets("PUR") 'Target worksheet that contains individual function tasks
Dim x
Dim y As Integer
Dim z As Integer
x = "AP" 'Row in MPP worksheet that contains tickmarks for specific function
y = 3 'Starting row in MPP worksheet (after headers)
z = 7 'Starting row in target worksheet (first row after headers)
t.Activate
t.Range("A7:M1000").Clear 'readies the target worksheet
Do While IsEmpty(m.Range("A" & y)) = False 'Checks to see if a task exists and ends the script if one doesn't--there are no gaps between tasks
If m.Range(x & y) = "1" Then
t.Range("B" & z).Value = m.Range("A" & y).Value 'Phase
t.Range("C" & z).Value = m.Range("B" & y).Value 'WBS
t.Range("D" & z).Value = m.Range("D" & y).Value 'ID #
t.Range("E" & z).Value = m.Range("F" & y).Value 'Task Name
t.Range("F" & z).Value = m.Range("G" & y).Value 'Start
t.Range("G" & z).Value = m.Range("H" & y).Value 'Due
t.Range("H" & z).Value = m.Range("J" & y).Value 'Day Type
t.Range("I" & z).Value = m.Range("K" & y).Value 'Required Attendees
t.Range("J" & z).Value = m.Range("L" & y).Value 'Assigned To
t.Range("K" & z).Value = m.Range("S" & y).Value 'Room / Address
t.Range("L" & z).Value = m.Range("T" & y).Value 'Equipment
t.Range("M" & z).Value = m.Range("E" & y).Value '% Complete <---this is the only one that comes out wrong.
z = z + 1
End If
y = y + 1
Loop
End Sub
Like I said, I'm at a loss as to what is happening. It seems like it should pull correctly since it's the same code that is used to pull everything else.
I can manually observe that nothing changes to the task when changing the sorting. In other words, task "A" on the master list will show 0% complete, irregardless of how the table is sorted, however it may get copied as 100% or 0%, depending on how the table is sorted.
Bookmarks