Could someone please explain what I have incorrect in the following code?
I get an error at the last line in the code = ActiveCell.PasteSpecial xlPasteValues
I am trying to have the range copy and paste into whatever cell is selected before the macro is run.
I get an error at the last line in the code = ActiveCell.PasteSpecial xlPasteValues
I am trying to have the range copy and paste into whatever cell is selected before the macro is run.
VBA Code:
Sub PopulateCEPrepYFP()
Dim arrRanges() As String
Dim arrWorksheets() As String
Dim Ws As Worksheet
Dim i As Integer
Dim ii As Integer
Dim intRow As String
Dim rng As Range
ActiveWorkbook.Save
Worksheets("CE Prep").Activate
With Worksheets("CE Prep")
.Range("Ag3:Ag" & .Cells(.Rows.Count, "AA").End(xlUp).Row).Value = ""
End With
arrRanges = Split("B8:B33,B39:B64,B70:B95,B101:B126", ",")
arrWorksheets = Split("YFP Amp Setup", ",")
intRow = 3
For i = LBound(arrWorksheets) To UBound(arrWorksheets)
For ii = LBound(arrRanges) To UBound(arrRanges)
For Each rng In Worksheets(arrWorksheets(i)).Range(arrRanges(ii))
If Len(Trim(rng.Value)) > 0 Then
Worksheets("CE Prep").Cells(intRow, 33).Value = rng.Value
intRow = intRow + 1
End If
Next rng
Next ii
Next i
Worksheets("CE Prep").Range("Ag3").Select
Worksheets("CE Prep").Range("AH2:Ak99").Copy
ActiveCell.PasteSpecial xlPasteValues
End Sub