Hi Guys,
I have a workbook with multiple sheets, What I want to achieve is to adapt this macro which I'm currently using which copies a range of data from each sheet to also paste a formula into each sheet and then include the answer the formula gives in the copying process.
---------------------------------------------------------------
Code:
Dim i As Integer
Dim wsname As String
For i = 2 To ThisWorkbook.Sheets.Count
Sheets(i).Select
wsname = Sheets(i).Name
Range("D950:F950,H950").Copy
Sheets(1).Select
Range("C5").Select
If ActiveCell.Value <> "" Then
If ActiveCell.Offset(1, 0).Value <> "" Then
ActiveCell.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
Else
ActiveSheet.Paste
End If
ActiveCell.Offset(0, -1).Value = wsname
Next i
---------------------------------------------------------
I want to paste the following formula into each sheet in cell G:950 and then copy the answer along with the other cells (D:950, E:950, F:950 & H:950)which would change the range to copy afterwards to 'D950:H950'
---------------------------------------------------------
Code:
=INDEX(G4:G947,MATCH(LARGE(Array2,1),Array2,0))
---------------------------------------------------------
If someone has any ideas that would be fantastic thank you!
I have a workbook with multiple sheets, What I want to achieve is to adapt this macro which I'm currently using which copies a range of data from each sheet to also paste a formula into each sheet and then include the answer the formula gives in the copying process.
---------------------------------------------------------------
Code:
Dim i As Integer
Dim wsname As String
For i = 2 To ThisWorkbook.Sheets.Count
Sheets(i).Select
wsname = Sheets(i).Name
Range("D950:F950,H950").Copy
Sheets(1).Select
Range("C5").Select
If ActiveCell.Value <> "" Then
If ActiveCell.Offset(1, 0).Value <> "" Then
ActiveCell.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Else
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
End If
Else
ActiveSheet.Paste
End If
ActiveCell.Offset(0, -1).Value = wsname
Next i
---------------------------------------------------------
I want to paste the following formula into each sheet in cell G:950 and then copy the answer along with the other cells (D:950, E:950, F:950 & H:950)which would change the range to copy afterwards to 'D950:H950'
---------------------------------------------------------
Code:
=INDEX(G4:G947,MATCH(LARGE(Array2,1),Array2,0))
---------------------------------------------------------
If someone has any ideas that would be fantastic thank you!