將主程式的值帶到Function中的MySht、MyBase後,
希望Function計算出來的RC1、RC2、CC1、CC2能讓主程式應用。
而我這個寫法無法將Function的值讓主程式使用,
請問程式碼有那邊需要修改呢?謝謝!!
程式碼如下:
Sub 主程式()
Dim RC1 as Integer, RC2 as Integer, CC1 as Integer, CC2 as Integer
Call 範圍計算("資料表", "AG")
Range("A" & RC1 & ":O" & RC2).Copy <-希望用Function的RC1、RC2的值
......
Range("Z" & CC1 & ":AD" & CC2).Copy
......
End Sub
Function 範圍計算(ByRef Mysht As String, MyBase As String) as Integer
Dim RC1 as Integer, RC2 as Integer, CC1 as Integer, CC2 as Integer
Sheets(Mysht).Select
RC1 = Range(MyBase & ActiveSheet.Rows.Count).End(xlUp).Row
RC2 = xxxxx
CC1 = xxxxx
CC2 = xxxxx
End Function