This is continuation of my question from here : How to looping rows and then columns in Excel
I have stumbled another roadblock as I pull all night over this issue: To recap:
I have a table as shown below (B1:L7) Where A1 is lookup values , row B is the header , row C to L is the data.
Column N is the visual representation of end result going to looked like. It is bolded and highlighted for clarity.
Note : Highly discouraged solutions of selecting the whole row and transpose paste due to there are conditional formatting at column N for further analysis.
Here is what I intend to do with the macro below:
- Loop the row B using the lookup values in A1 for matching- DONE
- Once macro found matching values to lookup values, (i.e :B6 shows matching values to A1) , the values of first 10 values (C to L) (i.e:row 6) are looped to show the values - DONE
All of 10 values are copied at columns N (starting N1 and reiterates downwards to N10) (i.e:C6 values are copied to N1 , D6 to N2 , etc...)- While iterating thru the rows , select the range and paste transpose the values selection in cell N1
Sub Looping_Click()
'Search columns
Dim c As Range
'Search rows
Dim r As Range
'Range to copy and paste values
Dim i As Range
For Each r In Range(Range("B1"), Range("B1").End(xlDown))
If r.Value = Range("A1").Value Then
MsgBox "Found values at " & r.Address
For Each c In Range(r.Offset(0, 1), r.Offset(0, 10))
MsgBox "Values is " & c.Value
''''''''''''''''''''''''''''''''''''''
MsgBox "Values is " & c.Value
r.Selection.Copy
Next i
''''''''''''''''''''''''''''''''''''''
Range("N1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next c
End If
Next r
End Sub
The problem is when I running macro, there are no values being pasted at column N as well as RunTimeError 438 pops out
I have highlighted the related / suspected troublesome macro parts with ''''


Application.Transposeto transpose the values.