Hi All,
I have two questions
Q1 :Can we Specify same column in multiple selection range for Example : Range("A2,B2,C2,A2,B2) and paste in the other sheet ?
Q2 : Can we specify blank columns in the multiple selection for example : Range("A2,"",B2,C2,"",D2) and paste in the other sheet ?
please guide me how i can handle these scenarios from VBA.
This is my code
Sub repdata()
Dim my_range As Range
Dim ws As Worksheet
Set my_range = ThisWorkbook.Sheets("Sheet1").Range("A2,B2,T2,V2")
Set ws = ThisWorkbook.Sheets("Sheet2")
Do
If Application.WorksheetFunction.CountA(my_range) > 0 Then
' my_range.UsedRange.Select
my_range.Copy
my_range.Copy ws.Range("A" & ws.Rows.Count).End(xlUp).Offset(1, 0)
Set my_range = my_range.Offset(1, 0)
Else
Exit Do
End If
Loop
End Sub
Regards,
Arafat
I have two questions
Q1 :Can we Specify same column in multiple selection range for Example : Range("A2,B2,C2,A2,B2) and paste in the other sheet ?
Q2 : Can we specify blank columns in the multiple selection for example : Range("A2,"",B2,C2,"",D2) and paste in the other sheet ?
please guide me how i can handle these scenarios from VBA.
This is my code
Sub repdata()
Dim my_range As Range
Dim ws As Worksheet
Set my_range = ThisWorkbook.Sheets("Sheet1").Range("A2,B2,T2,V2")
Set ws = ThisWorkbook.Sheets("Sheet2")
Do
If Application.WorksheetFunction.CountA(my_range) > 0 Then
' my_range.UsedRange.Select
my_range.Copy
my_range.Copy ws.Range("A" & ws.Rows.Count).End(xlUp).Offset(1, 0)
Set my_range = my_range.Offset(1, 0)
Else
Exit Do
End If
Loop
End Sub
Regards,
Arafat
Last edited: