P
PSULionRP
I am dynamically executing this function with a variable I want to calculate
within the Function. With this case, the last active row in an Excel
spreadsheet so that I can dynamically add a TOTAL Row.
The call looks like this...
GetLastActiveRow (0)
And the Function is defined as such...
Function GetLastActiveRow(pLastRow As Long)
Dim strAddress As String
Dim lngTotalRow As Long
Dim rngTable As Range
lngTotalRow = 1
Range("A2").Select
Set rngTable = ActiveCell.CurrentRegion
strAddress = rngTable.AddressLocal
lngTotalRow = CLng(Mid(strAddress, InStrRev(strAddress, "$") + 2))
lngTotalRow = pLastRow
End Function
When I return, I want to use the "pLastRow" variable and it is not allowing
me to do so.
GetLastActiveRow (0)
Dim myRange As String
Dim lngTotalRow As Long
lngTotalRow = pLastRow + 2
myRange = "A" & lngTotalRow
xl.Range(myRange).Select
xl.Selection = "TOTAL"
myRange = "D" & lngTotalRow
xl.Range(myRange).Select.Formula =
"=SUM(D3" & pLastRow & ")"
What do I have to do to pass this number back so that I can create my Excel
formula???
Thanks for your review and hopeful for a reply.
PSULionRP
within the Function. With this case, the last active row in an Excel
spreadsheet so that I can dynamically add a TOTAL Row.
The call looks like this...
GetLastActiveRow (0)
And the Function is defined as such...
Function GetLastActiveRow(pLastRow As Long)
Dim strAddress As String
Dim lngTotalRow As Long
Dim rngTable As Range
lngTotalRow = 1
Range("A2").Select
Set rngTable = ActiveCell.CurrentRegion
strAddress = rngTable.AddressLocal
lngTotalRow = CLng(Mid(strAddress, InStrRev(strAddress, "$") + 2))
lngTotalRow = pLastRow
End Function
When I return, I want to use the "pLastRow" variable and it is not allowing
me to do so.
GetLastActiveRow (0)
Dim myRange As String
Dim lngTotalRow As Long
lngTotalRow = pLastRow + 2
myRange = "A" & lngTotalRow
xl.Range(myRange).Select
xl.Selection = "TOTAL"
myRange = "D" & lngTotalRow
xl.Range(myRange).Select.Formula =
"=SUM(D3" & pLastRow & ")"
What do I have to do to pass this number back so that I can create my Excel
formula???
Thanks for your review and hopeful for a reply.
PSULionRP