Hello everyone,
I am new to VBA and I've looked for a lot of threads which could answer my questions but couldn't find any.
Here is my code so far:
Sub copyrows()
Dim tfCol As Range, Cell As Object
Set tfCol = Range("B36:B45")
For Each Cell In tfCol
If Cell.Value = [b13] Then
Cell.EntireRow.Copy
Sheets("Carteira").Activate
Selection.Offset(1).Insert
Selection.Offset(1).Select
ActiveSheet.PasteSpecial xlPasteValues
End If
Next
End Sub
I am having 3 problems with this code:
1 - I do not want to copy the entire row, but only the columns B to BH from that specific row (I guess I would need to do a loop, but I don't know how);
2 - I want to copy only the values and not the formulas or format.
3 - Since I am copying the entire row, the VBA code only runs when I select the column A from the worksheet "Carteira". Otherwise it gives me the run-time error '1004': "The copy area and the paste area are not the same size".
Thanks in advance!
I am new to VBA and I've looked for a lot of threads which could answer my questions but couldn't find any.
Here is my code so far:
Sub copyrows()
Dim tfCol As Range, Cell As Object
Set tfCol = Range("B36:B45")
For Each Cell In tfCol
If Cell.Value = [b13] Then
Cell.EntireRow.Copy
Sheets("Carteira").Activate
Selection.Offset(1).Insert
Selection.Offset(1).Select
ActiveSheet.PasteSpecial xlPasteValues
End If
Next
End Sub
I am having 3 problems with this code:
1 - I do not want to copy the entire row, but only the columns B to BH from that specific row (I guess I would need to do a loop, but I don't know how);
2 - I want to copy only the values and not the formulas or format.
3 - Since I am copying the entire row, the VBA code only runs when I select the column A from the worksheet "Carteira". Otherwise it gives me the run-time error '1004': "The copy area and the paste area are not the same size".
Thanks in advance!