
내가 검색한 대부분의 솔루션은 첫 번째 빈 열이나 첫 번째 빈 행을 찾는 것이었지만 특히 행 범위에서 첫 번째 빈 열을 찾아야 합니다.
필요한 것은 통합 문서의 내용을 다른 통합 문서에 붙여넣는 것입니다. 하지만 먼저 (100:114)의 행 범위에서 첫 번째 빈 열을 찾아야 합니다.
지금까지 가지고 있는 것을 게시할 수 있지만 작동하는 것과는 거리가 멀습니다.
답변1
따라서 내 VBA 기술은 완전히 녹슬었지만 Tom Urtis의 기여를 보면방법: 범위 선택Microsoft 개발자 네트워크에서 알 수 없는 시작 위치의 데이터 범위를 선택하면 수행하려는 작업에 대한 솔루션을 실행하는 데 필요한 개체와 메서드가 있습니다. 다음은 해당 링크의 코드를 다시 인쇄한 것입니다.
Sub UnknownRange()
If WorksheetFunction.CountA(Cells) = 0 Then
MsgBox "There is no range to be selected.", , "No cells contain any values."
Exit Sub
Else
Dim FirstRow&, FirstCol&, LastRow&, LastCol&
Dim myUsedRange As Range
FirstRow = Cells.Find(What:="*", SearchDirection:=xlNext, SearchOrder:=xlByRows).Row
On Error Resume Next
FirstCol = Cells.Find(What:="*", SearchDirection:=xlNext, SearchOrder:=xlByColumns).Column
If Err.Number <> 0 Then
Err.Clear
MsgBox _
"There are horizontally merged cells on the sheet" & vbCrLf & _
"that should be removed in order to locate the range.", 64, "Please unmerge all cells."
Exit Sub
End If
LastRow = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LastCol = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
Set myUsedRange = Range(Cells(FirstRow, FirstCol), Cells(LastRow, LastCol))
myUsedRange.Select
MsgBox "The data range on this worksheet is " & myUsedRange.Address(0, 0) & ".", 64, "Range address:"
End If
End Sub