I have a Sub that I Call in as part of another sub. When this is ran by itself it works fine but when it is called in from another sub it doesn't quite work exactly right. The main sub saves the default values and then:
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Call FillInCoding
Here is the sub that is not working and I think it might be this coding is copy and paste special-ing:
Sub FillInCoding()
'clears the area to be pasted into
Worksheets(1).Range("A11:G98567").ClearContents
Dim JE As Worksheet
Dim Sheet1 As Worksheet
Dim lastRow As Long
Set JE = ThisWorkbook.Worksheets(1)
Set Sheet1 = ThisWorkbook.Worksheets(2)
lastRow = Sheet1.Range("R65536").End(xlUp).Row
'This part is copying the values of the ranges from worksheet #2 into the worksheet #1 destination
Worksheets(2).Range("AM2:AM" & lastRow).Copy
Worksheets(1).Range("A11:A" & lastRow).PasteSpecial xlPasteValues
Worksheets(2).Range("AN2:AN" & lastRow).Copy
Worksheets(1).Range("B11:B" & lastRow).PasteSpecial xlPasteValues
Worksheets(2).Range("R2:R" & lastRow).Copy
Worksheets(1).Range("E11:E" & lastRow).PasteSpecial xlPasteValues
Worksheets(2).Range("AO2:AO" & lastRow).Copy
Worksheets(1).Range("G11:G" & lastRow).PasteSpecial xlPasteValues
End Sub
I tried setting the ranges but it was pasting the cell formulas instead of the values, so this was the only easy way I could get it to do what I needed it to do. At the end of the day I need what you see on sheet 2 in a varying range (each time it's ran it could be a different length) to be copied as a value into sheet 1.
If someone knows how to easily set ranges on different sheets as equal to varying values when the end row changes and they are in different spots on the different sheets that would be ideal.
For example on sheet two it might be
A1="XYZ"
B1="100000"
C1="52.00"
D1="office supplies"
A2="YZA"
B2="150000"
C2="-52.00"
D2="office supplies"
But in sheet one we need these values pasted in starting at A11:12, B11:12, C11:12, D11:12, etc (the next day though maybe there are 40 lines instead of 2 lines).