Re: [算表] 開啟檔案指定位置輸入vba

看板Office作者 (佩蒂吉他)時間9年前 (2017/02/14 14:54), 編輯推噓0(004)
留言4則, 2人參與, 最新討論串3/3 (看更多)
※ 引述《ptguitar (佩蒂吉他)》之銘言: : ※ 引述《ptguitar (佩蒂吉他)》之銘言: 其實還是一直卡關 後來用這樣的vba 可是copy過去還是一樣不行 用從比對的 對照到資料的標題 copy過去 原始檔案 https://drive.google.com/open?id=0BwCgrQhGgaw7bkM0RzM1eXM4YjQ 不知道是哪幾行的思考邏輯有誤可否幫我修改一下 感謝 Sub Ex() Dim E, F As Range Dim x, y, z, scell, tcell As String Dim startNum As Long Dim SS, TS As Worksheet Set SS = Sheets("比對") Set TS = Sheets("資料") x = Sheets("比對").Range("A2").End(xlDown).Row y = Sheets("資料").Range("A2").End(xlDown).Row + 1 startNum = 0 For Each E In SS.Range("A1:J1") scell = WorksheetFunction.Match(E, SS.Range("A1:J1"), 0) - 1 For Each F In TS.Range("A1:J1") tcell = WorksheetFunction.Match(F, TS.Range("A1:J1"), 0) - 1 If scell = tcell Then SS.Range("A2:A" & x).Offset(, tcell).Copy TS.Range("A" & y).Offset(, tcell) startNum = tcell Exit For End If Next Next End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.34.252.11 ※ 文章網址: https://www.ptt.cc/bbs/Office/M.1487055242.A.6BE.html

02/14 15:10, , 1F
02/14 15:10, 1F

02/14 15:13, , 2F
調整一下,將變數x和y宣告進去
02/14 15:13, 2F

02/14 15:47, , 3F
S大真感謝! 一直搞不清楚那些變數要怎麼加進去
02/14 15:47, 3F

02/14 15:47, , 4F
還要多看看S大這樣的高手怎麼寫才能進步 感謝~
02/14 15:47, 4F
文章代碼(AID): #1OegcAQ- (Office)
文章代碼(AID): #1OegcAQ- (Office)