I am in a dead end with a function() and a sub(). My code :
sub test()
Dim Firstrow, FirstCol As Integer
Workbooks("wb").Activate
Workbook(1).Worksheet(1).Select
FirstRow = 16
FirstCol = 20
LastCell = FindLastcell(FirstRow,FirstCol) 'LastCell is in "RiCj" format
FirstCell = Cells(FirstRow, FirstCol).Address(ReferenceStyle:=xlR1C1) 'FirstCell is in "RiCj" format
RngSelect = Range(FirstCell, LastCell).Select 'Range Method has failed. Obvious. See [1]
[more code to copy as text on Notepad the selection]
End Sub
Now my function :
Public Function FindLastCell(ByVal int1 As Integer, ByVal int2 As Integer) As Variant ' what kind of return dim shall I choose ?
' find first empty cell in a range and return its adress
LastRow = Cells(Rows.Count, int1).End(xlUp).Row
LastCol = Cells(int2, Columns.Count).End(xlToLeft).Column
FindLastCell = Cells(LastRow, LastCol).Address(ReferenceStyle:=xlR1C1)
End Function
After having tried many variants, I can not get the desired result. Best would be in fact:
- My function shall return a list or array of Integers to use as cell adress in this style Cells(int1,int2)
In my sub(), writing something like that:
RngSelect = Range(Cells(i,j),Cells(k,l)).Select
I do not know how to achieve this whitout trigering in my function or in my sub an error.
[1] http://msdn.microsoft.com/en-us/library/office/ff838238.aspx If you use a text argument for the range address, you must specify the address in A1-style notation (you cannot use R1C1-style notation).
Thank you for help.