Excel 하나의 셀에서 여러 수식(불가능할 수도 있음)

Excel 하나의 셀에서 여러 수식(불가능할 수도 있음)

우선 나는 이것이 극도로 어렵거나 불가능하다는 것을 알고 있다는 점부터 시작하고 싶습니다.

나는 데이터를 가지고 있습니다 (위키피디아, 항공사 및 목적지 목록의 모든 공항), 한 열에는 항공사 이름이 있고 다른 열에는 쉼표로 구분된 목적지 목록과 경우에 따라 추가 정보가 있습니다.

나에게 필요한 것은 항공사 이름이 옆에 있고 추가 정보(전세, 계절, "시작....", 참조)가 세 번째 열에 있는 별도의 행에 각 목적지를 가져오는 것입니다.

나는 여러 Wikipedia 테이블을 사용하여 이 작업을 반복적으로 수행할 것입니다. Kumu.io에서 노선도를 만들고 있습니다. 모든 솔루션이 모든 작업을 수행하지는 않아도 괜찮습니다. 모든 작업을 직접 수행할 수 있는 방법이 없기 때문에 가까운 작업이 필요합니다. 더 많은 정보가 필요하면 알려주세요. 도움을 주셔서 감사합니다. 이것은 정말 멋진 리소스입니다.

데이터는 이런 형식입니다

여기에 이미지 설명을 입력하세요

그리고 나는 그것이 다음과 같이 보일 필요가 있습니다

여기에 이미지 설명을 입력하세요

답변1

실제로 하이퍼링크가 있는지 여부에 대한 질문이 명확하지 않습니다(일부는 색상으로 표시되어 있고 일부는 밑줄이 그어져 있고 일부는 그렇지 않음).

워크시트 기능으로 이 작업을 수행할 수 있는지는 모르겠지만 VBa는 이를 수행합니다.

Option Explicit

Sub CrazyAirlines()

'************** There are things you may need to edit here

Dim currentRow As Integer
currentRow = 1 'I assume we start on row 1, if row 1 is actually headings, change this to the first row of data

Dim destinationRow As Integer
destinationRow = 1 ' assuming there is no heading again, if there is, change to a 2

Dim airlineCol As String
airlineCol = "A"

Dim destinationCol As String
destinationCol = "B"

Dim extraCol As String
extraCol = "C"

Dim origSheet As String
origSheet = "Sheet1" ' the name of of the sheet where the values currently live

Dim destSheet As String
destSheet = "Sheet2" ' this is the sheet name where the results will be

' *********** Hopefully you don't need to edit anything under this line!!

Worksheets(destSheet).Cells.Clear

Do While (Worksheets(origSheet).Range(airlineCol & currentRow).Value <> "")

    Dim airline As String
    airline = Worksheets(origSheet).Range(airlineCol & currentRow).Value

    Dim destinations As String
    destinations = Worksheets(origSheet).Range(destinationCol & currentRow).Value

    Dim extraInfo As String

    Dim title As String

    Dim spInfo() As String
    spInfo = Split(destinations, ":")

    If (UBound(spInfo) > 0) Then
        title = spInfo(0)
    End If

    destinations = Replace(destinations, title & ":", "")

    Dim spDest() As String
    spDest = Split(destinations, ",")

    Dim i As Integer

    For i = 0 To UBound(spDest)

        Worksheets(destSheet).Range(airlineCol & destinationRow).Value = RemoveSquare(Trim(airline))

        Dim des As String
        des = RemoveSquare(spDest(i))

        Dim containsExtra() As String
        containsExtra = Split(spDest(i), "(")

        If UBound(containsExtra) > 0 Then
            title = Replace(containsExtra(1), ")", "")
            des = containsExtra(0)
        End If

        Worksheets(destSheet).Range(destinationCol & destinationRow).Value = Trim(des)

        If (title <> "") Then
            Worksheets(destSheet).Range(extraCol & destinationRow).Value = title
            title = "" 'kill it, kaboom, bang, boom (not good words considering this is about airlines, but hilarious
        End If

        destinationRow = destinationRow + 1

    Next i

    currentRow = currentRow + 1
Loop

End Sub

Function RemoveSquare(s As String)

Dim sp() As String
sp = Split(s, "]")

    If UBound(sp) > 0 Then
        RemoveSquare = sp(1)
    Else
        RemoveSquare = s
    End If

End Function

Sheet1은 다음과 같습니다.

여기에 이미지 설명을 입력하세요

위의 VBa를 실행한 후 내 Sheet2는 다음과 같습니다.

여기에 이미지 설명을 입력하세요

관련 정보