SOLVED

Create a new table selecting info from an existing table in Excel vba

%3CLINGO-SUB%20id%3D%22lingo-sub-1941012%22%20slang%3D%22en-US%22%3ECreate%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1941012%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone!%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20trying%20to%20make%20a%20nice%20%3CSTRONG%3Etable%3C%2FSTRONG%3E%20(%3CEM%3Esheet%202%3C%2FEM%3E)%20%3CSTRONG%3Eout%20of%20different%20information%3C%2FSTRONG%3E%20about%20a%20company%20%3CSTRONG%3Efrom%20a%20bigger%20table%3C%2FSTRONG%3E%20(%3CEM%3Esheet1%3C%2FEM%3E).%20%3CFONT%20color%3D%22%230000FF%22%3EThe%20info%20is%20in%20different%20language%20and%20has%20more%20sections%20than%20needed%20to%20create%20the%20new%20table%20(intended%20to%20create%20a%20nice%20CV).%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3EThe%20goal%20is%20to%20create%20a%20%3CU%3EVBA%20that%20automatized%20this%3C%2FU%3E%20to%20gain%20time.%26nbsp%3B%3CBR%20%2F%3EI%20am%20so%20lost%20with%20this%20because%20I%20do%20not%20know%20anything%20about%20VBA%2C%20so%20I%20was%20hoping%20someone%20could%20help%2Fguide%20me.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20put%20an%20example%20of%20what%20I%20would%20like%20to%20create.%20So%20basically%20%3CFONT%20color%3D%22%230000FF%22%3Eall%20the%20different%20projects%20are%20on%20%3CEM%3Esheet%201%3C%2FEM%3E%20with%20all%20the%20different%20sections%20(%3Dcolumns)%20per%20project%3C%2FFONT%3E.%20On%3CEM%3E%20sheet%202%3C%2FEM%3E%2C%20%3CFONT%20color%3D%22%230000FF%22%3Ethere%20is%20the%20table%20I%20would%20like%20to%20be%20able%20to%20create%20with%20a%20VBA.%3C%2FFONT%3E%3CBR%20%2F%3E%3CBR%20%2F%3ELet%20me%20know%20if%20you%20are%20able%20to%20help%20me%2C%20I%20would%20be%20%3CSTRONG%3Eso%20grateful%3C%2FSTRONG%3E!!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ED%C3%A9borah%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1941012%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1941658%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1941658%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871689%22%20target%3D%22_blank%22%3E%40dfhidromod%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20the%20attached%20version%20(now%20a%20.xlsm%20workbook).%3C%2FP%3E%0A%3CP%3ERun%20the%20macro%20ShowForm.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1945572%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1945572%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871689%22%20target%3D%22_blank%22%3E%40dfhidromod%3C%2FA%3E%26nbsp%3B%20It%20is%20possible%20to%20do%20much%20of%20this%20with%20worksheet%20formulas.%26nbsp%3B%20I%20have%20use%20Excel%20365%20to%20put%20the%20entire%20calculation%20into%20a%20single%20formula%20in%20cell%20F1.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%5C0%2C%20%22Generate%20indices%22%2C%0A%20%20%20%20N%2C%20COUNTIF(Project%5BWorking%20Area%5D%2CCriterion)%2C%0A%20%20%20%20k%2C%20SEQUENCE(8*N%2C1%2C0)%2C%0A%20%20%20%20recordOffset%2C%20QUOTIENT(k%2C8)%2C%0A%20%20%20%20fieldOffset%2C%20MOD(k%2C8)%2C%0A%5C1%2C%20%22Filter%20fields%20and%20records%20to%20extract%20relevant%20data%22%2C%0A%20%20%20%20headers%2C%20FILTER(Project%5B%23Headers%5D%2CcolumnFilter)%2C%0A%20%20%20%20selectedFields%2C%20FILTER(Project%2C%20columnFilter)%2C%0A%20%20%20%20filteredKey%2C%20%20FILTER(Project%5BProjeto%5D%2C%20Project%5BWorking%20Area%5D%3DCriterion)%2C%0A%20%20%20%20filteredTable%2C%20FILTER(selectedFields%2C%20Project%5BWorking%20Area%5D%3DCriterion)%2C%0A%5C2%2C%20%22Assemble%20report%20recombining%20project%20key%20and%20selected%20data%22%2C%0A%20%20%20%20reportKey%2C%20INDEX(filteredKey%2C%201%2BrecordOffset)%2C%0A%20%20%20%20reportHeader%2C%20IF(fieldOffset%2C%20INDEX(headers%2C%201%2BfieldOffset)%2C%20%20reportKey)%2C%0A%20%20%20%20reportData%2C%20INDEX(filteredTable%2C%201%2BrecordOffset%2C%201%2BfieldOffset)%2C%0A%20%20%20%20report%2C%20CHOOSE(%7B1%2C2%7D%2C%20reportHeader%2C%20reportData)%2C%0A%20%20%20%20report%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20878px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236957i6E65A2663393C0A0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1970339%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1970339%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDear%20Peter%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%20a%20lot%20for%20your%20help!%20I%20see%20in%20your%20file%20that%20you%20got%20the%20exact%20result%20I%20wanted.%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20try%20to%20redo%20it%2C%20it%20does%20not%20work.%3C%2FP%3E%3CP%3ESo%20the%20pink%20table%20should%20select%20and%20filter%20the%20projects%20according%20to%20their%20working%20area%2C%20right%3F%3C%2FP%3E%3CP%3ESo%20for%20this%2C%20you%20used%20the%20formula%20%22%3D%20SORT(UNIQUE(Project%5BWorking%20Area%5D))%22%20but%20when%20I%20do%20it%2C%20it%20does%20not%20want%20to%20link%20both%20sheets%3A%20the%20one%20you%20named%20DataTable%20and%20Report.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20then%20on%20the%20left%20side%20of%20that%20same%20worksheet%20%22Report%22%2C%20you%20have%20%22N%3D%22%20in%20one%20cell%20and%20then%20%22%3DCOUNTIF(Project%5BWorking%20Area%5D%2CCriterion)%22%20which%20does%20not%20work%20either%20when%20I%20try%20it%20on%20my%20own%20file.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20think%20you%20know%20what%20is%20the%20problem%20here%3F%20and%20if%20yes%2C%20would%20you%20mind%20explaining%20it%20to%20me%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%20for%20your%20file%20again%2C%20when%20it%20will%20work%2C%20it%20will%20simplify%20and%20automatize%20so%20much%20my%20work!!%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1974045%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1974045%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871689%22%20target%3D%22_blank%22%3E%40dfhidromod%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20your%20table%20named%20'Project'%20or%20is%20it%20named%20as%20default%20'Table1'%20(or%20the%20equivalent%20in%20Portuguese).%3C%2FP%3E%3CP%3EFor%20the%20filtering%20to%20work%20you%20need%20to%20be%20using%20Excel%20365.%26nbsp%3B%20Otherwise%20the%20formulas%20get%20very%20messy.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1976951%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1976951%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDear%20Hans%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewhat%20a%20script!%20Thanks%20a%20lot!%3C%2FP%3E%3CP%3EHowever%20there%20are%20things%20I%20do%20not%20understand%20and%20I%20am%20having%20a%20hard%20time%20to%20reproduce%20the%20code%20on%20the%20real%20document.%3C%2FP%3E%3CP%3EIn%20these%20lines%3A%3C%2FP%3E%3CP%3E%26lt%3B%3CEM%3EFor%20r%20%3D%203%20To%20m%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EFor%20i%20%3D%201%20To%20n%3C%2FEM%3E%3CBR%20%2F%3E%3CEM%3EIf%20v(r%2C%2013)%20%3D%20arrSelected(i)%20Then%26gt%3B%26nbsp%3B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EWhy%20did%20you%20choose%203%20for%20r%20%3D3%3F%3C%2FLI%3E%3CLI%3Eand%20also%2C%20the%20v(r%2C13)%3D%20arrSelected(i)%2C%20what%20does%20it%20mean%3F%20why%2013%3F%3C%2FLI%3E%3CLI%3EWhat%20do%20%22A%22%20and%20%22B%22%20stand%20for%3F%20because%20there%20is%20nothing%20in%20Columns%20A%20and%20B%2C%20so%20I%20am%20guessing%20it%20is%20not%20referring%20to%20the%20columns.%20But%20what%20is%20it%20then%3F%3C%2FLI%3E%3C%2FOL%3E%3CP%3EI%20know%20you've%20already%20helped%20immensly%2C%20and%20I%20am%20novice%20in%20this%20language%2C%20but%20would%20appreciate%20if%20you%20took%20the%20time%20to%20answer%20me%20again%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ED%C3%A9borah%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1977197%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1977197%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871689%22%20target%3D%22_blank%22%3E%40dfhidromod%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EBecause%20the%20data%20on%20Sheet1%20start%20on%20row%203%20(row%201%20is%20hidden%20and%20row%202%20contains%20headers).%3C%2FLI%3E%0A%3CLI%3Ev%20is%20an%20array%20that%20contains%20the%20values%20of%20the%20cells%20in%20columns%20A%20to%20Y%2C%20row%201%20to%20m%20(the%20last%20used%20row).%20v(r%2C%2013)%20is%20the%20array%20element%20in%20row%20r%20and%20column%2013.%20Column%20number%2013%20corresponds%20to%20column%20M%2C%20the%20Working%20Area%20column.%3C%2FLI%3E%0A%3CLI%3EA%20and%20B%20are%20the%20columns%20on%20the%20%3CEM%3Enew%3C%2FEM%3E%20sheet%20that%20are%20filled%20by%20the%20code.%3C%2FLI%3E%0A%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1979233%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1979233%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOkay%20thanks%20for%20the%20explanations!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20one%20more%20thing%2C%20in%20this%20line%20%3CW.RANGE%3E%20what%20does%20the%20%3CSTRONG%3E4%2B%20s%3C%2FSTRONG%3E%20stands%20for%3F%3C%2FW.RANGE%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20at%20the%20end%20in%20this%20line%3A%20%3CW.RANGE%3E%20the%20%3CSTRONG%3EA1%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EB1%3C%2FSTRONG%3E%20correspond%20to%20the%20new%20sheet%20too%3F%20I%20am%20having%20troubles%20identifying%20where%20you%20set%20that%20the%20code%20opens%20a%20new%20sheet%20for%20these%20variables.%3C%2FW.RANGE%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1979326%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1979326%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871689%22%20target%3D%22_blank%22%3E%40dfhidromod%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20line%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3E%20%20%20%20Set%20w%20%3D%20Worksheets.Add(After%3A%3DWorksheets(Worksheets.Count))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ecreates%20a%20new%20worksheet%20and%20assigns%20it%20to%20the%20variable%20w%2C%20so%20in%20the%20rest%20of%20the%20code%2C%20we%20can%20use%20w%20to%20refer%20to%20the%20new%20sheet.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20variable%20s%20contains%20a%20number%20representing%20the%20selected%20language%3A%201%20for%20Portuguese%2C%202%20for%20English%20etc.%3C%2FP%3E%0A%3CP%3EI%20see%20now%20that%204%20%2B%20s%20should%20have%20been%203%20%2B%20s.%20This%20is%20the%20column%20number%20containing%20the%20titles%20in%20that%20language%3A%20column%204%20(D)%20for%20Portuguese%2C%205%20(E)%20for%20English%20etc.%3C%2FP%3E%0A%3CP%3EI%20will%20attach%20a%20corrected%20workbook.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20w.Range(%22A1%3AB%22%20%26amp%3B%20t).Borders%2C%20w%20is%20the%20new%20sheet%2C%20so%20this%20line%20refers%20to%20columns%20A%20and%20B%20on%20the%20new%20sheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1979522%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20a%20new%20table%20selecting%20info%20from%20an%20existing%20table%20in%20Excel%20vba%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1979522%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOkay!%20Starting%20to%20understand%20better!%20This%20code%20is%20really%20impressive%20and%20cool.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20it%20on%20my%20new%20worksheet%20(because%20I%20had%20to%20add%20things)%20(and%20adapting%20the%20code%20to%20it)%2C%20but%20when%20I%20select%20the%20languages%2C%20nothing%20happens.%20I%20don't%20even%20get%20an%20error%20message.%20There%20is%20just%20nothing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20file%20attached%20to%20this%20message%2C%20there%20are%20the%20headers%20I%20am%20using%20and%20their%20positions%20in%20the%20worksheet.%20I%20thought%20I%20changed%20everything%20I%20needed%20to%20make%20it%20work%2C%20but%20does%20not%20seem%20to%20give%20me%20results.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20think%20you%20could%20have%20a%20look%20at%20the%20changes%20I%20made%20to%20your%20code%20and%20identify%20what%20I've%20missed%3F%3C%2FP%3E%3CP%3EI%20marked%20all%20the%20changes%20in%20green%20with%20this%20%22%20'%20%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi everyone!

I am trying to make a nice table (sheet 2) out of different information about a company from a bigger table (sheet1). The info is in different language and has more sections than needed to create the new table (intended to create a nice CV). 

The goal is to create a VBA that automatized this to gain time. 
I am so lost with this because I do not know anything about VBA, so I was hoping someone could help/guide me. 

 

I put an example of what I would like to create. So basically all the different projects are on sheet 1 with all the different sections (=columns) per project. On sheet 2, there is the table I would like to be able to create with a VBA.

Let me know if you are able to help me, I would be so grateful!!!

 

Cheers,

 

Déborah

13 Replies

@dfhidromod 

See the attached version (now a .xlsm workbook).

Run the macro ShowForm.

@dfhidromod  It is possible to do much of this with worksheet formulas.  I have use Excel 365 to put the entire calculation into a single formula in cell F1.

= LET(
\0, "Generate indices",
    N, COUNTIF(Project[Working Area],Criterion),
    k, SEQUENCE(8*N,1,0),
    recordOffset, QUOTIENT(k,8),
    fieldOffset, MOD(k,8),
\1, "Filter fields and records to extract relevant data",
    headers, FILTER(Project[#Headers],columnFilter),
    selectedFields, FILTER(Project, columnFilter),
    filteredKey,  FILTER(Project[Projeto], Project[Working Area]=Criterion),
    filteredTable, FILTER(selectedFields, Project[Working Area]=Criterion),
\2, "Assemble report recombining project key and selected data",
    reportKey, INDEX(filteredKey, 1+recordOffset),
    reportHeader, IF(fieldOffset, INDEX(headers, 1+fieldOffset),  reportKey),
    reportData, INDEX(filteredTable, 1+recordOffset, 1+fieldOffset),
    report, CHOOSE({1,2}, reportHeader, reportData),
    report )

image.png

@Peter Bartholomew 

Dear Peter,

 

thanks a lot for your help! I see in your file that you got the exact result I wanted. 

However, when I try to redo it, it does not work.

So the pink table should select and filter the projects according to their working area, right?

So for this, you used the formula "= SORT(UNIQUE(Project[Working Area]))" but when I do it, it does not want to link both sheets: the one you named DataTable and Report. 

 

And then on the left side of that same worksheet "Report", you have "N=" in one cell and then "=COUNTIF(Project[Working Area],Criterion)" which does not work either when I try it on my own file. 

 

Do you think you know what is the problem here? and if yes, would you mind explaining it to me?

 

Thanks a lot for your file again, when it will work, it will simplify and automatize so much my work!!

 

Regards

@dfhidromod 

Is your table named 'Project' or is it named as default 'Table1' (or the equivalent in Portuguese).

For the filtering to work you need to be using Excel 365.  Otherwise the formulas get very messy.

@Hans Vogelaar 

Dear Hans,

 

what a script! Thanks a lot!

However there are things I do not understand and I am having a hard time to reproduce the code on the real document.

In these lines:

<For r = 3 To m
For i = 1 To n
If v(r, 13) = arrSelected(i) Then> 

 

  1. Why did you choose 3 for r =3?
  2. and also, the v(r,13)= arrSelected(i), what does it mean? why 13?
  3. What do "A" and "B" stand for? because there is nothing in Columns A and B, so I am guessing it is not referring to the columns. But what is it then?

I know you've already helped immensly, and I am novice in this language, but would appreciate if you took the time to answer me again

 

Regards,

 

Déborah

@dfhidromod 

  1. Because the data on Sheet1 start on row 3 (row 1 is hidden and row 2 contains headers).
  2. v is an array that contains the values of the cells in columns A to Y, row 1 to m (the last used row). v(r, 13) is the array element in row r and column 13. Column number 13 corresponds to column M, the Working Area column.
  3. A and B are the columns on the new sheet that are filled by the code.

@Hans Vogelaar 

 

Okay thanks for the explanations!

 

And one more thing, in this line <w.Range("B" & t).Value = v(r, 4 + s)> what does the 4+ s stands for?

 

And at the end in this line: <w.Range("A1:B1" & t).Borders....etc> the A1 and B1 correspond to the new sheet too? I am having troubles identifying where you set that the code opens a new sheet for these variables.

 

Cheers!

@dfhidromod 

The line

    Set w = Worksheets.Add(After:=Worksheets(Worksheets.Count))

creates a new worksheet and assigns it to the variable w, so in the rest of the code, we can use w to refer to the new sheet.

 

The variable s contains a number representing the selected language: 1 for Portuguese, 2 for English etc.

I see now that 4 + s should have been 3 + s. This is the column number containing the titles in that language: column 4 (D) for Portuguese, 5 (E) for English etc.

I will attach a corrected workbook.

 

In w.Range("A1:B" & t).Borders, w is the new sheet, so this line refers to columns A and B on the new sheet.

@Hans Vogelaar 

Okay! Starting to understand better! This code is really impressive and cool.

 

I tried it on my new worksheet (because I had to add things) (and adapting the code to it), but when I select the languages, nothing happens. I don't even get an error message. There is just nothing.

 

In the file attached to this message, there are the headers I am using and their positions in the worksheet. I thought I changed everything I needed to make it work, but does not seem to give me results. 

 

Do you think you could have a look at the changes I made to your code and identify what I've missed?

I marked all the changes in green with this " ' "

 

Cheers!

best response confirmed by dfhidromod (Occasional Contributor)
Solution

@dfhidromod 

The major problem: you changed cmdCancel_Click to cmdCancel_Click3 and cmdOK_Click to cmdOK_Click3. That won't work: Click is the name of the event, you can't just change that.

Other problems: the headers are now in row 1 instead of row 2, and your column offsets for the context and activity were off by 1.

See the attached version.

@Hans Vogelaar 

okay, I see! thanks for the explanation!

 

Another last thing, do you know how to define the width of the 2nd column in the new sheet created?

Because, i get super wide columns and the text does not fit in it

 

Attached, there is a picture illustrating better what I'm trying to explain.

 

All the best,

 

Déborah

 

@dfhidromod 

Hopefully, this works better.