How can I copy from specific sheet in excel

0 votes

I used the following VBA code to try to consolidate numerous pages into one sheet:

Sub Combine()
    Dim J As Integer
    Dim s As Worksheet

    On Error Resume Next
    Sheets("Operational").Activate
    Range("A1:A2").EntireRow.Select
    Selection.Copy Destination:=Sheets("Combined").Range("A1:A2")

    For Each s In ActiveWorkbook.Sheets
        If s.Name <> "Combined" And _
           s.Name <> "Probability & Impact" And _
           s.Name <> "Escalation Criteria" And _
           s.Name <> "Application list" And _
           s.Name <> "Dashboard" Then
            Application.GoTo Sheets(s.Name).[a1]
            Selection.CurrentRegion.Select
            ' Don't copy the headings
            Selection.Offset(2, 0).Resize(Selection.Rows.Count - 1).Select
            Selection.Copy Destination:=Sheets("Combined"). _
              Cells(Rows.Count, 1).End(xlUp)(2)
        End If
    Next
      Sheets("Combined").Activate
End Sub

The document has numerous tabs, thus all I need to do is unite 4 sheets into one called (Combain). The last document was copied three times, which is the problem. Is there a remedy for that?

Oct 28 in Others by Kithuzzz
• 20,660 points
23 views

1 answer to this question.

0 votes
You should use wb.Sheets("Name of sheet").Copy - best to be explicit about the workbook you're copying from. Plus if you're copying from more than one file you can't have two sheets with the same name in the destination workbook.
answered Oct 29 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer

How can I open a URL in Android's web browser from my application?

ry this: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri ...READ MORE

answered Jun 14 in Others by polo
• 1,480 points
1,015 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24 in Others by narikkadan
• 37,660 points
65 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
454 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,227 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
71 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
210 views
0 votes
1 answer
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15 in Others by narikkadan
• 37,660 points
115 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP