Home » Php » VBA Excel, PHP MySQL – data loop, transponse, range, list views, arrays

VBA Excel, PHP MySQL – data loop, transponse, range, list views, arrays

Posted by: admin October 28, 2018 Leave a comment

Questions:

BEFORE and AFTER IMAGE (https://i.stack.imgur.com/lwn4h.png)

As shown in the image above, I’m trying to achieve a result as shown in AFTER table from the data in BEFORE table.

These are what I want us to achieve:

  1. Uniquely transpose department from columns into rows
  2. Uniquely List all vendor that is tired to each location, office and department – separated by comma for multiple vendors

I have so far been able to write a sub routine that is able to copy the department data and transpose it, but I’m stock moving forward.

Range("D4:D18").Select
Range("D4:D18").Sort key1:=Range("D4"), _
    order1:=xlAscending, Header:=xlNo
Selection.Copy
Range("CJ3").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
Application.CutCopyMode = False

and giving it a try on mySQL:

SELECT DISTINCT location, department, office, GROUP_CONCAT(vendor) as vendor FROM `tbl_dep_ven_location` WHERE department = 'Procurement' and location = 'Femty' GROUP BY office ORDER by depterment
Answers: