TA Arjun
TA Arjun

Reputation: 25

Copy a specific range of data from one sheet to other

Hi I am trying to copy a specific range of data i.e. A7 till A10000 and C7 till C10000 of one sheet to A1 and B1 cells of the other sheet. but I am not able to do that using the below

Sheets("Appointment").Columns("A7").Copy Destination:=Sheets("Security Appt_Location").Range("A1")
Sheets("Appointment").Columns("C7").Copy Destination:=Sheets("Security Appt_Location").Range("B1")

Can I define the range in the above sentences?

Upvotes: 0

Views: 61

Answers (2)

David Zemens
David Zemens

Reputation: 53623

Columns("A7") is an invalid specification. Columns are identifed by letter or index, e.g., Columns("A") or Columns(1).

If you fix that, the code should work, barring some other circumstances like worksheet protection, etc.

Upvotes: 1

Tim Williams
Tim Williams

Reputation: 166146

You're only copying a single cell, and your code would benefit from a little reworking to reduce duplication:

  Dim sht
  Set sht = Sheets("Security Appt_Location")

  With Sheets("Appointment")
     .Range("A7:A10000").Copy Destination:=sht.Range("A1")
     .Range("C7:C10000").Copy Destination:=sht.Range("B1")
  End With

Upvotes: 0

Related Questions