2015-03-31 39 views
0

我真的需要在沒有剪貼板的情況下粘貼值,這是我輸入UDF的單元格下面的單元格。下面的單元格粘貼值如果下面的單元格不是空白的

例如用下面的代碼

Function macropastec5() As Variant 
macropastec5 = Sheets("Sheet1").Range("H7").Value 
End Function 

,如果我進入細胞H6 = macropastec5()

所以我將如何利用這個任意單元格來獲得它下面的單元格?

我需要像成才

Function macropastec5(the cell I'd enter in excel formula bar ) As Variant 
macropastec5 = Sheets("Sheet1").Range(" the cell below where I enter in formula bar").Value 
End Function 

回答

0

只要使用此功能,請輸入您的範圍的功能。例如,如果您使用該函數並輸入C1,則該函數將從C2複製值,因爲我將該行增加一個。希望這可以幫助。

Public Function CopyBelowCell(rng As Range) As Variant 

Dim rw As Long 
Dim col As Long 

rw = rng.Row 
col = rng.Column 

CopyBelowCell = Cells(rw + 1, col) 

End Function 
相關問題