View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Combining data from multiple worksheets.

Sorry, didn't realize this was the General Question site and not the
Programming site. People ask the same questions on both sites.

This is VBA code which is another name for a macro or subroutine or function.

The code is referencing the worksheet names on the bottom of the spreadsheet
(sheet1,sheet2,sheet3). Change these names if they don't match you
worksheets. You called them W1, W2, W3.

You have to copy and paste this code into the VBA. The code starts at the
word "SUB" and ends at "END SUB".

Now follow these instructions.

1) Go to Tools MENU - MACRO - Visual Basic Editor
2) From VBA window - INSERT MENU - MODULE
3) Paste code in this window.
4) Go back to worksheet
5) Run macro by going to Tools MENU - MACRO - MACRO - MOVEDATA (this is the
name of the subroutine that you added to the VBA window)

The macro just ran and the data should be moved to the 3rd worksheet.


"Olmsted57" wrote:

Joel-

Thanks for the help, BUT... I'm kind of a rookie :-( Can you tell me what
to do with this?

Thanks a million!

"Joel" wrote:

Sub movedata()

With Sheets("sheet1")
Lastrow = _
.Cells(Rows.Count, "A").End(xlUp).Row
Set copyrange = _
Range(.Cells(1, "A"), .Cells(Lastrow, "A"))
End With

RowCount = 1
For Each cell In copyrange
If Not IsEmpty(cell) Then
Sheets("Sheet3").Cells(RowCount, "A") = cell
RowCount = RowCount + 1
End If
Next cell

With Sheets("sheet2")
Lastrow = _
.Cells(Rows.Count, "A").End(xlUp).Row
Set copyrange = _
Range(.Cells(1, "A"), .Cells(Lastrow, "A"))
End With

For Each cell In copyrange
If Not IsEmpty(cell) Then
Sheets("Sheet3").Cells(RowCount, "A") = cell
RowCount = RowCount + 1
End If
Next cell

End Sub


"Olmsted57" wrote:

I have 3 worksheets (W1, W2, W3). W1 has data in cells A1 through A10 (in a
worksheet that has 25 rows). W2 has data in cells A1 through A5 (in a
worksheet that has 25 rows). I would like W3 to list W1 A1:A10, then W2
A1:A5 in its A column, but ignoring any blank rows. HELP!!!! I know there
must be an easy way to do this!