VBA copy data to another sheet

June 20, 2017 at 19:03:03
Specs: Windows 7
Hello there,

Does anyone know why VBA do not allow me to copy from cell ab2 onwards on "Raw data" tab to cell a3 onwards on "Detail list" tab using the code below?

Worksheets("Raw data").Range("ab2:ab" & Range("ab2").End(xlDown).Row).Copy _
Destination:=Worksheets("Detail list").Range("a3")

But this code works:

Worksheets("Raw data").Range("ab2:ab" & Range("ab2").End(xlDown).Row).Copy _
Destination:=Worksheets("Detail list").Range("a2")

How do I solve it?


See More: VBA copy data to another sheet

Reply ↓  Report •

#1
June 20, 2017 at 19:25:28
re: "Does anyone know why VBA do not allow me to copy from cell ab2 onwards on "Raw data" tab to cell a3 onwards on "Detail list" tab using the code below?"

Yes!

I'll give you 2 hints and then let you figure it out.

Hint #1: How many rows are there in an Excel spreadsheet (assuming Excel 2007 or later)?

Hint #2: Run this code:

Sub WhatsMyAddress()
 MsgBox Range("ab2:ab" & Range("ab2").End(xlDown).Row).Address
End Sub

When you figure it out, come back and explain it so we know that you know. ;-)

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Reply ↓  Report •

#2
June 20, 2017 at 19:45:44
Thanks DerbyDad..... I don't get it T.T.................... sorry this whole VBA things are totally new to me..

Reply ↓  Report •

#3
June 20, 2017 at 21:04:50
How many Rows of data do you have in Column AB?

BTW...what do you mean by "VBA do not allow me to copy"?

Does it give you an error?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Reply ↓  Report •

Related Solutions

#4
June 20, 2017 at 21:53:34
I have about 50,000 rows in column AB..

yes VBA gives an error message: Run-time error'10004': Application-defined or object-defined error....


Reply ↓  Report •

#5
June 20, 2017 at 22:55:33
Basically I want to do this:

From

	Raw data sheet
	Column ab
row 1	zone1
row 2	zone2
row 3	zone3
row 4	zone4
row 5	zone5
row 6	zone6
row 7	zone7
row 8	zone8
row 9	zone9

to

	Detail list sheet
	Column a
row 1	leave blank
row 2	zone1
row 3	zone2
row 4	zone3
row 5	zone4
row 6	zone5
row 7	zone6
row 8	zone7
row 9	zone8
row 10	zone9


Reply ↓  Report •

#6
June 21, 2017 at 06:49:01
Your code does not match what you say you want to do.

Your code says to start copying from AB2, yet your example data starts in Row 1 and the Row 1 data appears to have been pasted into your example Row 2. Therefore I assume that you want it copied.

Why doesn't your code include Row 1 in the range to be copied?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Reply ↓  Report •

Ask Question