VBA to copy from first sheet in a workbook only

anj123

New Member
Joined
Jun 15, 2015
Messages
5
Hi,

I'm a VBA beginner and have a macro to copy data from specific cells in a worksheet into a worksheet in a master workbook. I will be using this macro for multiple workbooks in a folder.

My problem is that every workbook in the folder has multiple worksheets. I only want to copy from the first worksheet in each workbook (the name of this worksheet varies for each workbook but is always the first tab in each workbook). I've been able to find solutions to copy from all worksheets in a workbook but not from a specific worksheet. Is anyone able to help?

Many thanks!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
.......

My problem is that every workbook in the folder has multiple worksheets. I only want to copy from the first worksheet in each workbook (the name of this worksheet varies for each workbook but is always the first tab in each workbook). .......


Are you looking for something along these lines...

Code:
[color=blue]Dim[/color] ws [color=blue]As[/color] Worksheet
[color=blue]Set[/color] ws = ActiveWorkbook.Worksheets.Item(1)

. Provided your first Tab was the initial first Tab ( Sheet1 ) in the workbook, than this would access the “first” Tab in any workbook just opened, regardless of its actual name

Alan
 
Upvote 0

Forum statistics

Threads
1,206,921
Messages
6,075,590
Members
446,147
Latest member
homedecortips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top