How do I pull data from multiple worksheets into one?



How do I pull data from multiple worksheets into one?..

Answer / Harsh Mani Singh

"To pull data from multiple worksheets into one, you can use Excel's VBA (Visual Basic for Applications). Here is a simple example:

1. Press Alt + F11 to open the VBA editor.
2. Click on Insert > Module.
3. Paste the following code:

```vba
Sub PullData()
Dim SourceSheet As Worksheet
Dim DestinationSheet As Worksheet
Dim LastRowSource As Long
Dim LastRowDest As Long

Set SourceSheet = ThisWorkbook.Sheets("Sheet1") 'Change to the source sheet name
Set DestinationSheet = ThisWorkbook.Sheets("Sheet2") 'Change to the destination sheet name

LastRowSource = SourceSheet.Cells(SourceSheet.Rows.Count, "A").End(xlUp).Row
LastRowDest = DestinationSheet.Cells(DestinationSheet.Rows.Count, "A").End(xlUp).Row + 1

DestinationSheet.Range("A" & LastRowDest).Resize(SourceSheet.Rows.Count).Value = SourceSheet.Range("A1:A" & LastRowSource).Value
```

4. Press Ctrl + S to save the module, and Close the VBA editor."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MS Excel Microsoft Interview Questions

Can you do pivot tables in excel?

1 Answers  


What is the default excel font?

1 Answers  


How do I change my excel settings?

1 Answers  


How do you fix a cell in excel?

1 Answers  


Is tableau better than excel?

1 Answers  


What is a macro in excel? How to create an excel macro?

1 Answers  


What does consolidate mean in excel?

1 Answers  


How do you combine formulas in excel?

1 Answers  


What is the order of precedence for excel operators?

1 Answers  


Why is f4 not working in excel?

1 Answers  


How do you automatically fill serial number in excel without dragging?

1 Answers  


How does counta work in excel?

1 Answers  


Categories