Compiling multiple worksheets - Add additional columns with static data

stefk

New Member
Joined
Jul 25, 2019
Messages
4
Hi everyone. In a bit of a pickle again!

I have some vba code that compiles a fixed range of cells across multiple worksheets into a single consolidated sheet. So far so good.

What I would like to do now, is to add some additional columns to all the consolidated data with some of the attributes of the analysis that I am using. For example:


Sheet Revenue Costs Data Run dateUsername File name
Sheet 1452.34234.6505/08/2019skconsol file
Sheet 27984.342234.3405/08/2019skconsol file
Sheet ..................

<tbody>
</tbody>


So my existing macro covers the first two columns in Blue, which are dynamic and based on the calculations in the sheets between the bookends. But it is the columns in red that I am stuck on, which will be static based on that particularly run of the analysis. These columns are populated with the same info for all line items where there are values.

A few other things:
  • There could be a variable number of sheets for consolidation - they are within two bookends called "start" and "end"
  • The red columns will always come from the same location - for now lets call this the range A1:A5 in a sheet called "static"
  • I would like the copy paste attributes to follow that of the existing code, i.e. look for the next blank row and populate
  • I have a paste special:transpose function. So in my code below, column CU corresponds to column BA after transposition

In advance, your help is greatly appreciated!



Code:
Sub compiler2()
   
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

Dim i As Long


    Application.Calculation = xlCalculationManual
   
   For i = Sheets("start").Index + 1 To Sheets("end").Index - 1
      Sheets(i).Range("J3:CU4,J23:CU29,J35:CU54,J56:CU58,J62:CU71,J74:CU84").Copy
      Worksheets("consol").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues, Transpose:=True
   Next i
   Application.CutCopyMode = False
   Application.ScreenUpdating = True
   Application.Calculation = xlCalculationAutomatic
   
   
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,213,484
Messages
6,113,924
Members
448,533
Latest member
thietbibeboiwasaco

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