Merge cells from all worksheets into a master worksheet

P

pmv464

I am attempting to use the macro as written, from
http://www.rondebruin.nl/copy2.htm. I have tried using the "Copy a range of
each sheet" macro and also the "Copy from row 2 till the last row with data"
macro. Each time I try to run them I get " Compile error:sub or function not
defined" and visual basic is highlighting the following

For Each sh In ThisWorkbook.Worksheets
If sh.Name <> DestSh.Name Then
Last = LastRow(DestSh) LastRow is highlighted
shLast = LastRow(sh)

Is there something I need to define?
 
R

Ron de Bruin

Hi pmv464

Read good

On top of the page

Important: The macro examples use the functions that you can find in the last section of this page

And above the macro
Note: This example use the function LastRow

Copy the LastRow function also in the standard module
 
M

mvk

You need to enter this code in as well to define the function lastrow. The
code was at the bottom of the page where the code was.

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

MVK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top