복사 할 범위를 선택하면서 새 통합 문서로 테이블을 복사하고 첫 번째 열 ("A")가 자동으로 복사됩니다. (행은 문제가되지 않습니다. 모두 복사해야합니다) 예를 들어, 나는 28 개의 행과 10 개의 열로 구성된 표를 가지고 있습니다. A1 : A28 (첫 번째 열, 모든 행)에 추가 된 모든 열이있는 열 5와 8을 복사하기 만하면됩니다. 그게 내가 지금까지 가지고 있지만 작동하지 않습니다. 당신은 그것을 해결하시기 바랍니다VBA Excel 새 통합 문서에 테이블 복사 및 붙여 넣기 어떤 열을 복사 할 것인지 선택
Sub CommandButton1_Click()
Dim newWB As Workbook, currentWB As Workbook
Dim newS As Worksheet, currentS As Worksheet
Dim CurrCols As Variant
Dim rng As rang
'Copy the data you need
Set currentWB = ThisWorkbook
Set currentS = currentWB.Sheets("Feuil1")
'select which columns you want to copy
CurrCols = InputBox("Select which column you want to copy from table (up to 10)")
If Not IsNumeric(CurrCols) Then
MsgBox "Please select a valid Numeric value !", vbCritical
End
Else
CurrCols = CLng(CurrCols)
End If
'Set rng = currentWB.currentS.Range(Cells(1, A), Cells(27, CurrCols)).Select
currentS.Range("A1:A27").Select
Selection.copy
Set rng = currentWB.currentS.Range(Cells(1, CurrCols), Cells(28, CurrCols)).Select
rng.copy
'Create a new file that will receive the data
Set newWB = Workbooks.Add
With newWB
Set newS = newWB.Sheets("Feuil1")
newS.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
End Sub
을 도와 드릴까요? 미리 감사드립니다!
실제로 무엇을 의미 _ "모든 행과 열 (5)과 8 복사"_입니까? 입력 및 출력 데이터의 게시물 예제 – user3598756
예를 들어, 나는 28 개의 라인과 A부터 G까지의 컬럼으로 구성된 테이블을 가지고있다. Output으로 나는 28 개의 라인과 A, C, F의 컬럼을 얻고 싶다. 입력 (그래서 그것은 내 입력에서 가져온 세 개의 열로 구성되어) – Zigouma
어디에서 코드를 얻을 수 있습니까? 1) "입력"테이블 2) 열을 선택해야합니까? – user3598756