VBA Help (Newbie)

JMcAnarney

New Member
Joined
Nov 2, 2021
Messages
20
Office Version
  1. 2016
Platform
  1. Windows
  2. Web
Question,

What is the VBA code I would need to write in order to create a long list from all the sheets on my excel document. For example, I need to compile (similar to a data set) the cell range of L49 to AD49 down to L62 to AD62. I am doing it this way in order to compile out large data set in hopes to create a PIVOT table. The other way would be copying and pasting which would take far too long.

The code I have established combines ALL the sheets information which is what I do not want; just that specified range:

Sub Combine()
'UpdatebyExtendoffice20180205
Dim I As Long
Dim xRg As Range
On Error Resume Next
Worksheets.Add Sheets(1)
ActiveSheet.Name = "Combined"
For I = 2 To Sheets.Count
Set xRg = Sheets(1).UsedRange
If I > 2 Then
Set xRg = Sheets(1).Cells(xRg.Rows.Count + 1, 1)
End If
Sheets(I).Activate
ActiveSheet.UsedRange.Copy xRg
Next
End Sub



Any help?
 
Yes, sorry for confusion. I probably meant the long way as opposed to MACRO would be to copy and paste. I apologize for not being clear!
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
If you want a link, I think you would need to loop through every cell in the range for every sheet, which is likely to be slow.
Why can't you just have the values on the master sheet?
 
Upvote 0
Actually values are fine becuase if they were to change I would just need to rerun macro. Sorry for confusion
 
Upvote 0
Ok, how about
VBA Code:
Sub JMcAnarney()
   Dim Ws As Worksheet, Nws As Worksheet
   
   If Evaluate("isref('Master Summary'!A1)") Then
      Set Nws = Sheets("Master Summary")
   Else
      Set Nws = Sheets.Add(Sheets(1))
      Nws.Name = "Master Summary"
   End If
   For Each Ws In Worksheets
      If Ws.Name <> "Master Summary" Then
         Nws.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(14, 19).Value = Ws.Range("L49:AD62").Value
      End If
   Next Ws
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,614
Members
449,039
Latest member
Mbone Mathonsi

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