Sub Macro1() ' ' Macro1 ' ' upravuje nakopirovane zaznamy z FamilySearch (cez #zaznamyFS.iim) vo formate html ' 'Sheets("Hárok1").Select 'Sheets("Hárok2").Select 'ActiveWindow.SelectedSheets.Delete Sheets("Hárok1").Select Sheets("Hárok1").Copy After:=Sheets(1) Sheets("Hárok1 (2)").Select Sheets("Hárok1 (2)").Name = "Hárok2" Range("A1").Select ' zrus spojene bunky a zalamovanie textu podla bunky Cells.Select Selection.UnMerge With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = True .Orientation = 0 .AddIndent = False .IndentLevel = -1 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With With Selection .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With ' vlož stĺpce pre dátum a miesto Columns("D:E").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ' vlož stĺpce pre meno otca, matku a jej meno Columns("G:I").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ' pomenuj slĺpce Range("D2").Select ActiveCell.FormulaR1C1 = "datum" Range("E2").Select ActiveCell.FormulaR1C1 = "miesto" Range("F2").Select ActiveCell.FormulaR1C1 = "otec" Range("G2").Select ActiveCell.FormulaR1C1 = "meno_otca" Range("H2").Select ActiveCell.FormulaR1C1 = "matka" Range("I2").Select ActiveCell.FormulaR1C1 = "meno_matky" 'presun "matku" do rovnakeho riadku ako je osoba resp. "otec" Dim myRange, uprRange As Range Range("A1").Select ActiveCell.SpecialCells(xlLastCell).Select riadkov = ActiveCell.Row stlpcov = ActiveCell.Column Set myRange = ActiveSheet.Range(Cells(1, 1), Cells(riadkov, stlpcov)) Range("C3:C" & CStr(riadkov)).Select 'udalosť !! Set xRng = Selection x = "baptism:" For Each xR In xRng If Trim(CStr(xR.Value)) = x Then Range("C" & CStr(xR.Row + 1)).Cut Destination:=Range("D" & CStr(xR.Row)) 'dátum Range("C" & CStr(xR.Row + 2)).Cut Destination:=Range("E" & CStr(xR.Row)) 'miesto End If Next xR Range("F3:F" & CStr(riadkov)).Select 'rodičia !! Set xRng = Selection x = "father:" y = "mother:" posun = 2 For Each xR In xRng If Trim(CStr(xR.Value)) = x Then 'father Range("F" & CStr(xR.Row + 1)).Cut Destination:=Range("G" & CStr(xR.Row)) 'meno_otca posun = 2 End If If Trim(CStr(xR.Value)) = y Then 'mother Range("F" & CStr(xR.Row + 1)).Cut Destination:=Range("I" & CStr(xR.Row - posun)) 'meno_matky Range("F" & CStr(xR.Row + 0)).Cut Destination:=Range("H" & CStr(xR.Row - posun)) 'mother posun = 0 End If Next xR ' vymaž zbytočné stĺpce Range("A1").Select Range("A:A,F:F,H:H,J:J,K:K").Select Selection.Delete Shift:=xlToLeft Rows("1:1").Select Selection.Delete Shift:=xlUp Cells.EntireColumn.AutoFit Selection.RowHeight = 15 'zatried data a odstran zbytocne veci Range("A1").Select ActiveCell.SpecialCells(xlLastCell).Select riadkov = ActiveCell.Row stlpcov = ActiveCell.Column Set myRange = ActiveSheet.Range(Cells(1, 1), Cells(riadkov, stlpcov)) myRange.Select ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=ActiveCell. _ Offset(0, 3).Range(Cells(1, 1), Cells(riadkov, 1)), SortOn:=xlSortOnValues, Order:=xlAscending, _ DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.Sort .SetRange ActiveCell.Range(Cells(1, 1), Cells(riadkov, stlpcov)) .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With ActiveCell.SpecialCells(xlLastCell).Select r2 = ActiveCell.Row s2 = ActiveCell.Column Range("C1").Select Selection.End(xlDown).Select r1 = ActiveCell.Row rr = r1 & ":" & r2 + 1 Rows(rr).Select Selection.Delete Range("A1").Select 'dopln chybajuce stlpce a hlavicku Columns("B:E").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Selection.Font.Underline = xlUnderlineStyleNone With Selection.Font .ColorIndex = xlAutomatic .TintAndShade = 0 End With Columns("H:L").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Columns("O:R").Select Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove Rows("1:1").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Rows("1:1").Select Selection.Font.Bold = True Range("A1").Select ActiveCell.FormulaR1C1 = "osoba" Range("B1").Select ActiveCell.FormulaR1C1 = "m1" Range("C1").Select ActiveCell.FormulaR1C1 = "m2" Range("D1").Select ActiveCell.FormulaR1C1 = "meno" Range("E1").Select ActiveCell.FormulaR1C1 = "priezvisko" Range("F1").Select ActiveCell.FormulaR1C1 = "udalosť" Range("G1").Select ActiveCell.FormulaR1C1 = "dátum" Range("H1").Select ActiveCell.FormulaR1C1 = "m3" Range("I1").Select ActiveCell.FormulaR1C1 = "m4" Range("J1").Select ActiveCell.FormulaR1C1 = "d" Range("K1").Select ActiveCell.FormulaR1C1 = "m" Range("L1").Select ActiveCell.FormulaR1C1 = "r" Range("M1").Select ActiveCell.FormulaR1C1 = "miesto" Range("N1").Select ActiveCell.FormulaR1C1 = "otec" Range("O1").Select ActiveCell.FormulaR1C1 = "m5" Range("P1").Select ActiveCell.FormulaR1C1 = "m6" Range("Q1").Select ActiveCell.FormulaR1C1 = "meno_o" Range("R1").Select ActiveCell.FormulaR1C1 = "priezvisko_o" Range("S1").Select ActiveCell.FormulaR1C1 = "matka" Range("T1").Select ActiveCell.FormulaR1C1 = "m7" Range("U1").Select ActiveCell.FormulaR1C1 = "m8" Range("V1").Select ActiveCell.FormulaR1C1 = "meno_m" Range("W1").Select ActiveCell.FormulaR1C1 = "priezvisko_m" Range("A1").Select Cells.EntireColumn.AutoFit ' dopln vzorce Range("B2").Select ' osoba ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(FIND("" "", TRIM(RC[-1]))), FIND("" "", TRIM(RC[-1])), 0)" Range("C2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0, IF(ISNUMBER(FIND("" "", TRIM(RC[-2]), RC[-1]+1)), FIND("" "", TRIM(RC[-2]), RC[-1]+1), RC[-1]), 0)" Range("D2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]=0, """", TRIM(LEFT(RC[-3], RC[-1]-1)))" Range("E2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-2]=0, TRIM(RC[-4]), RIGHT(TRIM(RC[-4]), LEN(TRIM(RC[-4]))-RC[-2]))" Range("H2").Select ' dátum ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(FIND("" "", RC[-1])), FIND("" "", RC[-1]), 0)" Range("I2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0, IF(ISNUMBER(FIND("" "", RC[-2], RC[-1]+1)), FIND("" "", RC[-2], RC[-1]+1), RC[-1]), 0)" Range("J2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-2]=RC[-1], """", LEFT(RC[-3], RC[-2]-1))" Range("K2").Select ActiveCell.FormulaR1C1 = "=IF(RC[-3]