Selecting same column in multiple selection vba

Arafat

Board Regular
Joined
May 3, 2011
Messages
61
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
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top