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?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Where do you want to copy the 1st set of data to?
 
Upvote 0
I would like to put it on a separate page called "Master Summary" which would be the first sheet of doc
 
Upvote 0
But which cell would it start in?
 
Upvote 0
on the new page? A1. And the data it is pulling from is L49 to AD49 down to L62 to AD62. That help??
 
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
         Ws.Range("L49:D49").Copy Nws.Range("A" & Rows.Count).End(xlUp).Offset(1)
      End If
   Next Ws
End Sub
 
Upvote 0
Okay looks better here is what I changed it to get my data:

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
Ws.Range("L49:AD62").Copy Nws.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next Ws
End Sub


However the data needs to be an abolsute reference to the particular sheet it is pulling from; currently it is either just referenced to the mastersheet or it is just pulling the word its self hard coded.


1639496451508.png
 
Upvote 0
Do you need to keep the formulae, or are you happy to just have it converted to values?
 
Upvote 0
What I would like is the following IF possible: all those lines = a sheet name so cell would ='121005.00'!B48 and so on and so forth for all cells.

Does that make sense?
 
Upvote 0
So you are not trying to copy data, as your OP states, you are trying to link cells on the master sheet to cells on the other sheets?
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,733
Members
449,185
Latest member
hopkinsr

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