Gantt Chart Woes (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Ciao regazzi!

As I am sure must of you can empathize, I am a lone Access user in an Excel world (work place)

I receive schedules daily from two different sources that I use to plan events. Of course they are elaborate, busy, colorful Gantt-style Excel charts. I provided a bare-bones example.

What I want to do is easy to explain, but I cannot figure out how to do it.

I want to be able to have my application use the chart and write records to a table. For this example, it would write records as such:

Name | Event | Start | End |
Tom | Work | 1/1/18 | 1/7/18
Tom | Travel | 1/8/18 | 1/11/18
Tom | Vacation | 1/12/18 | 1/16/18
Dick | Travel | 1/1/18 | 1/4/18
Dick | Vacation | 1/5/18 | 1/9/18
Dick | Sick | 1/10/18 | 1/13/18
Harry | Work | 1/1/18 | 1/16/18

Seems pretty straight forward but for the life of me I cannot figure out how to do it.

Any ideas?
 

Attachments

  • TomDickHarry.xlsx
    9.9 KB · Views: 108

jleach

Registered User.
Local time
Today, 16:05
Joined
Jan 4, 2012
Messages
308
EDIT: I misunderstood, please disregard this reply (if a mod can remove it, go for it)


I've never actually found a good way to do Gantt charts in Access. In fact, I tend to disdain any charting in Access.

If you have a little bit of web experience and want to go out on a limb, try hooking up a web browser control and running a javascript charting library (which are typically much easier to use, IME - and look a lot nicer too).

I have a demo on my site for how to do this in 2010+ with a locally hosted web "applet" of sorts, and the ability to get two-way events and interactivity from charts. It works pretty nice once it's set up (although admittedly, the setup could be a lot easier: the latest release was still rough around the edges).

https://dymeng.com/resources/browse-embed/

Cheers
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Thanks for the input jleach, but I think you may have misunderstood. I do NOT want to make a chart, I want to take a chart that is given to me and convert it to records for a table.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
No worries, it looks like a neat feature that someone may be able to use...leave it!
 

plog

Banishment Pending
Local time
Today, 15:05
Joined
May 11, 2011
Messages
11,643
For nasty data like this I create an extraction spreadsheet. In it is a source tab and a data tab. I paste the nasty data onto the source tab run code that goes line by line over the source data and extracts it into an importable layout onto the data tab. Then I import the data tab into Access.

That code is never fun to write, but ultimate is a time saver if this is an often repeated process.
 

jleach

Registered User.
Local time
Today, 16:05
Joined
Jan 4, 2012
Messages
308
This actually looks like a real PITA. I'm hardly an Excel guru, but I think if I had to take on the task it'd go something like this:

1) Open the file via automation from Access
2) Find the row with months, determine the "spread" of columns for each month (e.g., Jan: B-AF), repeat and stuff the start/stop into an array/collection for each month until there's no more months to process
3) drop into the next row, gather all of the dates and their respective cells for each month, store in a nested array/collection of some sort (so one collection for Months, which in turns contains a collection of cells for each date of that month: probably UDTs to map out the data structures and an array to hold them).
4) Loop the rest of the rows with content:
4.1) track the person's name and match it up however you need to,
4.2) grab the next cell to the right and determine it's start/stop column. Example Tom Work between B and H. Store this "schedule value" (work) and the start/stop column in the appropriate UDT.
4.3) move to the next cell and start again

After that, you'd have a full map of the data stored in VBA and you can close out your excel instance then set about parsing out the data in the UDTs to ultimately format it as you need.

Might be an easier way, but I'm not sure you can retain the merged cells via any traditional import to Access, so I think automating Excel to read the structures is going to be required.

I'll be interested to see what other ideas get tossed out.

(hopefully this is a little more on point with what you need!) Cheers
 

isladogs

MVP / VIP
Local time
Today, 21:05
Joined
Jan 14, 2017
Messages
18,212
I did, sorry. I edited my post to reflect that. Not sure how to delete it.

Hi Jack

To delete a post, click the Edit button then delete this message

There is no time limit here for editing or deleting posts

Having said that the general rule here is to NOT delete posts once anyone has answered.
 

Mark_

Longboard on the internet
Local time
Today, 13:05
Joined
Sep 12, 2017
Messages
2,111
Is this for just a hand full of people or are you dealing with entire FTNs rotating in/out?
 

plog

Banishment Pending
Local time
Today, 15:05
Joined
May 11, 2011
Messages
11,643
I used an .xlsm file which is a filetype I can't upload. So here's just the code:

Code:
Sub populate_Output()
' loops through Input tab and extracts data to Output tab

Dim wb_Input As Worksheet: Set wb_Input = ThisWorkbook.Sheets("Input")
Dim wb_Output As Worksheet: Set wb_Output = ThisWorkbook.Sheets("Output")
    ' references to Input and Output tabs

Dim str_LastCellA As String: str_LastCellA = "Error"  ' value of prior row's A cell
Dim str_ThisCellA As String: str_ThisCellA = "Error"  ' value of current row's A cell

Dim str_Acct As String: str_Acct = "Error"          ' Account value to use for Output tab record
Dim str_Customer As String: str_Customer = "Error"  ' Customer value to use for Output tab record

Dim int_InputRow: int_InputRow = 1                  ' what row of Input to read from
Dim int_OutputRow: int_OutputRow = 2                ' what row of Output to write to

Dim int_ColStart: int_ColStart = 1                  ' what Input column to start with when copying a row of data
Dim int_ColEnd: int_ColEnd = 11                     ' what Input column to end with when copying a row of data

Dim counter_i: counter_i = int_ColStart             ' counter, to loop through columns to copy


'   **********      Above:  Variables         **********
'   **********      Below   Processing        **********


Do While str_LastCellA <> "End"
    ' loops through Input rows extracting data to Output tab
    
    str_ThisCellA = wb_Input.Cells(int_InputRow, 1)
    
    If str_ThisCellA = "" Then
    ' found blank row, sets Customer and Account to error values
        str_Customer = "Error"
        str_Acct = "Error"
        End If
     
    If IsDate(str_ThisCellA) Then
    ' on a row that needs to be extracted to Output
 
        wb_Output.Cells(int_OutputRow, 1) = str_Acct
        wb_Output.Cells(int_OutputRow, 2) = str_Customer
    ' puts Account and Customer values into Output row
        
        For counter_i = int_ColStart To int_ColEnd
    ' copies selected columns from Input to Output
            wb_Output.Cells(int_OutputRow, counter_i + 2) = wb_Input.Cells(int_InputRow, counter_i)
        Next
         
        int_OutputRow = int_OutputRow + 1
    ' moves Output data go to next row to write on
         End If

    If Left(str_ThisCellA, 4) = "Acct" Then
    ' on an account row, will get Account and Customer data
        str_Acct = Mid(str_ThisCellA, 8, 9)
        str_Customer = Mid(str_ThisCellA, InStr(str_ThisCellA, "-") + 2)
    End If
    
    int_InputRow = int_InputRow + 1
    ' moves Input tab to next row
  
    If (str_LastCellA = "") And (str_ThisCellA = "") Then str_LastCellA = "End" Else str_LastCellA = str_ThisCellA
   ' if 2 blank A cells in a row, process is done
Loop


End Sub

It wasn't 'source' and 'data', I actually used tabs called 'Input' and 'Output'. This also wasn't a Gantt chart, but some other type of nasty data with header sections and then rows of data that corresponded to that header data.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Is this for just a hand full of people or are you dealing with entire FTNs rotating in/out?

FTNs? Not quite sure what you mean, but the people do limited deployments, sometimes up to 6 months and then drop off.
 

isladogs

MVP / VIP
Local time
Today, 21:05
Joined
Jan 14, 2017
Messages
18,212
Here's a starting point ....with no code

Save the Excel file in CSV format.
Close & reopen it in Excel to get this



Now click on a populated cell & drag across to fill all blank cells
If you can, do it one month at a time & remove the first row to get this



Next use the Excel Transpose function to get this



Import into Access in the usual way

If you use the Excel Record Macro feature on the Developer tab, you can semi automate it

OK its not fully normalised but the last part can be done in Access using queries
OR you could do the transpose one row at a time to get a fully normalised dataset before importing
 

Attachments

  • CSV1.PNG
    CSV1.PNG
    6.2 KB · Views: 537
  • CSV2.PNG
    CSV2.PNG
    9 KB · Views: 511
  • Transpose.PNG
    Transpose.PNG
    20 KB · Views: 515

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Not bad Colin...not a perfect solution, but a far cry better than what I had. Still chewing on what Plog provided. Takes me a little while to decipher code...
 

isladogs

MVP / VIP
Local time
Today, 21:05
Joined
Jan 14, 2017
Messages
18,212
If its only going to be done once or twice I wouldn't bother with code.
If its going to be a regularly repeated PITA, then I would use code

Not sure why I added Name in cell A1 - that didn't help
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Going to be done twice every day, so a Module would be ideal. As it stands now, someone painstakingly hand jams them in - we are shown 3 months at a time - and then they check them everyday for changes.

I have gone as far as to offer a scheduling app to both units in either Access or SharePoint but getting folks to change something they are comfortable with is damn near impossible. They know Excel and until Microsoft discontinues it, we are stuck like chuck.
 

Mark_

Longboard on the internet
Local time
Today, 13:05
Joined
Sep 12, 2017
Messages
2,111
FTNs? Not quite sure what you mean, but the people do limited deployments, sometimes up to 6 months and then drop off.

Force Tracking Number. What J3/5 uses when doing unit rotations. As I understand some of the G shops use the same format or send down to who ever is expecting the unit to rotate in. UGLY format that changes depending on who is providing the unit.

Course you have people who are merging cells to make their charts, so I can't say that's going to be any easier!
 

Auntiejack56

Registered User.
Local time
Tomorrow, 06:05
Joined
Aug 7, 2017
Messages
175
Wow! Try this:
Dim n As Long, i As Long

For n = 1 To 20
If Len(Cells(n, 1)) > 0 Then
Debug.Print Cells(n, 1)
For i = 2 To 27
If Cells(n, i).MergeArea.Count > 1 Then
Debug.Print Cells(n, i) & " for " & Cells(n, i).MergeArea.Count & " days starting on day " & i - 1
End If
i = i + Cells(n, i).MergeArea.Count - 1
Next
End If
Next

You get this:
Tom
Work for 7 days starting on day 1
Travel for 4 days starting on day 8
Vacation for 5 days starting on day 12
Dick
Travel for 4 days starting on day 1
Vacation for 5 days starting on day 5
Sick for 4 days starting on day 10
Harry
Work for 16 days starting on day 1
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 16:05
Joined
Apr 27, 2015
Messages
6,328
Force Tracking Number. What J3/5 uses when doing unit rotations.

And here I thought I thought I was concealing the military “smell” so well. Well since you outed me, I will give full disclosure.

Tom, Dick and Harry are actually US Navy ships whose schedules are given to me daily by the respective Task Force Commanders for their fleets. I have the misfortune of having to do this for the 6th Fleet (Europe) and 5th Fleet (Middle East).

Doing these schedules is like bowling: everyone has their own way of doing it wrong. And, to make matters even more challenging, these schedules change quite frequently and now that the good Commander if Chief has managed to piss off everone East of Isreal, it is going to be even worse.

There IS about 91.2% uniformity so I should be able to write a mod that will suffice.

Plog’s and AuntJack’s code look promising but I will have to wait until I am at work to try it out since everything is on a classified system.
 

Mark_

Longboard on the internet
Local time
Today, 13:05
Joined
Sep 12, 2017
Messages
2,111
Can't mix blue and red cables... Got it.

If this is something they are required to submit, you should be able to push up to higher to request a uniform format. That works much better if you can sell HiCon on what you need under the guise of "Here's how I can get you the data you want, but I need subordinate units to provide it in the following format".

I've had to deal with joint commands before and I know getting these kinds of things to work is often not easy.
 

Users who are viewing this thread

Top Bottom