How to select the range for pasting using vba
- by user1616384
I wrote some code for selecting the particular row and pasting it in column wise using paste-special property. It is working correctly my code is :
lngRow = Me.TextBox4.Value
strCol = Me.TextBox5.Value
Set rng = Range("A:A").Find(What:=lngRow, LookIn:=xlValues, LookAt:=xlWhole)
If rng Is Nothing Then
MsgBox "Value not found in row 1", vbExclamation
Else
Range(rng, rng.End(xlToRight)).Copy
Range("A1:E3").Columns(strCol).Offset(, 1).PasteSpecial Transpose:=True
Range("A1:E3").Rows(1).Copy
Range("A1:E3").Columns(strCol).PasteSpecial Transpose:=True
endif
the problem here is I am using
Range(rng, rng.End(xlToRight)).Copy
to copy the values
and for pasting I am using Range("A1:E3").Columns(strCol).Offset(, 1).PasteSpecial Transpose:=True.
How can I paste all the values which are copied? Because if the values are in column F then this macro will not paste those values.