반응형
3개 이상을 조합하는것 가능하나, 시스템이 다운 될수 있습니다
code
Sub 모든조합()
Dim lastRowA As Long, lastRowB As Long, lastRowC As Long
Dim i As Long, j As Long, k As Long, L As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' 데이터가 있는 시트 이름 변경
lastRowA = ws.Cells(Rows.Count, "A").End(xlUp).Row
lastRowB = ws.Cells(Rows.Count, "B").End(xlUp).Row
lastRowC = ws.Cells(Rows.Count, "C").End(xlUp).Row
lastRowD = ws.Cells(Rows.Count, "D").End(xlUp).Row
' 결과를 출력할 시트와 시작 위치 설정
Dim resultSheet As Worksheet
Set resultSheet = ThisWorkbook.Sheets.Add
Dim nextRow As Long
nextRow = 1
For i = 1 To lastRowA
For j = 1 To lastRowB
For k = 1 To lastRowC
For L = 1 To lastRowD
resultSheet.Cells(nextRow, 1) = ws.Cells(i, "A").Value
resultSheet.Cells(nextRow, 2) = ws.Cells(j, "B").Value
resultSheet.Cells(nextRow, 3) = ws.Cells(k, "C").Value
resultSheet.Cells(nextRow, 4) = ws.Cells(L, "D").Value
nextRow = nextRow + 1
Next L
Next k
Next j
Next i
End Sub
'VBA VB.Net Code' 카테고리의 다른 글
Select the file name in the cell and open it (0) | 2024.09.11 |
---|---|
Excel Cell 내용 가져오기, Cell에 내보내기 (0) | 2024.09.09 |
학습 04) Open API, 엑셀 VBA (0) | 2024.06.24 |
학습 03) Open API, 엑셀 VBA (0) | 2024.06.24 |
JSON 활용 방법 (0) | 2024.06.21 |