2013-09-05 2 views
-1

VBA에서 Sheet1의 "Apple"(행 a1)이라는 셀 헤더를 찾고 해당 데이터를 Sheet2의 Orange라는 셀 헤더에 붙여 넣으십시오.Sheet1의 셀에서 값 찾기 및 Sheet2에 붙여 넣기

Sheet1  Sheet2 

Apple  Orange 
1 
2 
3 
4 
나는 단지 수를 잡고 있도록 세포 헤더를 포함하지하려고

.

겠습니까 뭔가 작업을 아래처럼?가 공동을하지 않도록하는 것이

Sheet1.Rows("1:1").Find(What:="Apple", After:=ActiveCell, LookIn:=xlFormulas, _ 
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ 
     MatchCase:=False, SearchFormat:=False).Activate 
Selection.EntireColumn row-1.Copy sheet2.range("a2") 

뭔가 entirecolumn row -1처럼 py 헤더 셀 ...
내가 무엇을하고 있는지 확실하지 않지만 도움이 될 것입니다!

+0

를 시도? 복사/붙여 넣기가 필요하지 않습니다. sheet2의 범위에있는 내용을 sheet1의 범위와 일치시키는 다른 방법이 있습니다. – datatoo

+0

'찾기()'가 이동하는 것처럼 보입니다. –

+0

글쎄 주셔서 감사합니다,하지만 두 시트는 ​​열을 변경하므로 실제로 열 두 시트를 일치시킬 수 없습니다 – GimGanDi

답변

0

안된를 : 당신은 무엇을

Dim rng as range, rngCopy as range, rng2 as range 

set rng = Sheet1.Rows(1).Find(What:="Apple", LookIn:=xlValues, LookAt:=xlWhole) 

if not rng is nothing then 

    set rngCopy = Sheet1.range(rng.offset(1,0), _ 
           Sheet1.cells(rows.count,rng.column).end(xlUp)) 

    set rng2 = Sheet2.Rows(1).Find(What:="Orange", LookIn:=xlValues, _ 
            LookAt:=xlWhole) 

    if not rng2 is nothing then rngCopy.copy rng2.offset(1,0) 

end if 
관련 문제