Copy a Range of Data to another Work Sheet
Public GetRealLastCell(sh as Worksheet) as range
Should be
Public Function GetRealLastCell(sh as Worksheet) as range
--
Regards,
Tom Ogilvy
"Theo Degr" wrote:
Tom,
Thank you. I am getting a Compile Error when entering the following Line:
Public GetRealLastCell(sh as Worksheet) as range
The word "as" is highlighted I am not sure why.
"Tom Ogilvy" wrote:
the below untested pseudocode should get you going:
Sub copydata()
Dim sh1 as Worksheet, sh2 as Worksheet
Set rng1 as range, rng2 as Range
set sh1 = Worksheets("Time Sheet")
set sh2 = Worksheets("Tme Record")
set rng1 = sh1.Range("A11:X26")
set rng2 = GetRealLastCell(sh2)
set rng2 = sh2.cells(rng2.row+1,1)
rng1.copy
rng2.pasteSpecial xlValues
End Sub
Public GetRealLastCell(sh as Worksheet) as Range
Dim RealLastRow As Long
Dim RealLastColumn As Long
On Error Resume Next
RealLastRow = _
sh.Cells.Find("*", Sh.Range("A1"), , , xlByRows, xlPrevious).Row
RealLastColumn = _
sh.Cells.Find("*", sh.Range("A1"), , , xlByColumns, xlPrevious).Column
set GetRealLastCell = sh.Cells(RealLastRow, RealLastColumn)
End Function
--
Regards,
Tom Ogilvy
"Theo Degr" wrote:
I have created some Macros using the already posted suggestions but I am
having trouble finding one that fits my current need. I am hoping that
someone out here can help me.
I am trying to copy a Range of Data "a11:x26" from one Work Sheet "Time
Sheet" to another Work Sheet "Time Record." I need the Macro to per form a
couple of tasks. First it would need to perform the copy. The copy would need
to be the values only of the cells. Then the next time that I would need to
copy the data it would need to find the next empty row on the Work Sheet
"Time record." Could someone please help me.
Thank you,
Ted
|