N
nc
I have a few sheets of data with same header and I would
like to put them on the same sheet? What is the easiest
way?
like to put them on the same sheet? What is the easiest
way?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
message news:[email protected]...-----Original Message-----
Try this nc
http://www.rondebruin.nl/copy2.htm
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
message news:[email protected]...-----Original Message-----
You forgot to copy the Function LastRow
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
message news:[email protected]...-----Original Message-----
You forgot to copy the Function LastRow
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
message news:[email protected]...-----Original Message-----
For Each sh In ActiveWindow.SelectedSheets
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
message news:[email protected]...-----Original Message-----
Try this
For Each sh In ThisWorkbook.Worksheets
If sh.Name <> DestSh.Name Then
Last = LastRow(DestSh)
If Last = 0 Then
sh.Range("A1:C1").Copy DestSh.Cells (Last + 1, "A")
Last = 1
End If
sh.Range("A2:C5").Copy DestSh.Cells(Last + 1, "A")
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
message news:[email protected]...-----Original Message-----
I only copy a part of the code
See the things I changed
I add this lines to the sub
If Last = 0 Then
sh.Range("A1:C1").Copy DestSh.Cells(Last + 1, "A")
Last = 1
End If
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
-----Original Message-----
Ron
Thanks.
I could not follow any of the changes you suggested. Can
you please send me the full code including copying only
the selected sheets.
message news:[email protected]... a-----Original Message-----
I only copy a part of the code
See the things I changed
I add this lines to the sub
If Last = 0 Then
sh.Range("A1:C1").Copy DestSh.Cells(Last + 1, "A")
Last = 1
End If
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote inuse1, "D").Value
=
message news:[email protected]...-----Original Message-----
You are right
I did not test it <g>
Add the master sheet manual to your workbook
and delete the code that create the master sheet
You can use it then
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
nc said:Ron
Thanks a lot. The managed to follow your suggestion. I
am still unsure about the selected sheets. That is
deleting the lines for adding the "Master" sheet.
message news:[email protected]...-----Original Message-----
Try this example
Add a Sheet named Master to you workbook before you run it.
DestSh.Cells.ClearContents
Every time you run the macro this line clear the contents of the cells in the
"Master" sheet before it add the cells from the selected sheets
Sub Test1()
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
Application.ScreenUpdating = False
Set DestSh = Sheets("Master")
DestSh.Cells.ClearContents
For Each sh In ActiveWindow.SelectedSheets
If sh.Name <> DestSh.Name Then
Last = LastRow(DestSh)
If Last = 0 Then
sh.Range("A1:C1").Copy DestSh.Cells(Last + 1, "A")
Last = 1
End If
sh.Range("A2:C5").Copy DestSh.Cells(Last + 1, "A")
DestSh.Cells(Last + 1, "D").Value = sh.Name
End If
Next
Application.ScreenUpdating = True
End Sub
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
--
Regards Ron de Bruin
http://www.rondebruin.nl
"nc" <[email protected]> wrote in
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.