ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   why won't this vba work, when this one does... (https://www.excelbanter.com/excel-programming/375225-why-wont-vba-work-when-one-does.html)

Calle

why won't this vba work, when this one does...
 
works:
Set sourceRange = mybook.Worksheets(1).Rows("1:150")
Set destrange = basebook.Worksheets("import").Rows(Lr)
That code copies row 1-150 and paste it into the first empty row, however I
want it to copy all rows that is not empty...

doesn't wrok:
Set sourceRange = mybook.Worksheets(1).Columns("A:K")
Set destrange = basebook.Worksheets("import").Rows(Lr)
I want it to copy column A-K and paste it into the first empty row

Jim Rech

why won't this vba work, when this one does...
 
You can only copy an entire column into an entire column. If you do not
actually want to copy an entire column then refine the source range to match
the range of data to be copied.

--
Jim
"Calle" wrote in message
...
| works:
| Set sourceRange = mybook.Worksheets(1).Rows("1:150")
| Set destrange = basebook.Worksheets("import").Rows(Lr)
| That code copies row 1-150 and paste it into the first empty row, however
I
| want it to copy all rows that is not empty...
|
| doesn't wrok:
| Set sourceRange = mybook.Worksheets(1).Columns("A:K")
| Set destrange = basebook.Worksheets("import").Rows(Lr)
| I want it to copy column A-K and paste it into the first empty row



Calle

why won't this vba work, when this one does...
 
Hi!
I have tried this, but it doesnt seem to work:

Set sourceRange = mybook.Worksheets(1).Rows("A1",
Range("A1").End(xlDown)).EntireRow.Copy
Set destrange = basebook.Worksheets("import").Rows(Lr)

Dave Peterson

why won't this vba work, when this one does...
 
Maybe...

With myBook.Worksheets(1)
Set SourceRange = .Range("A1", .Range("a1").End(xlDown))
End With
Set DestRange = BaseBook.Worksheets("import").Rows(LR)
SourceRange.EntireRow.Copy _
Destination:=DestRange

Calle wrote:

Hi!
I have tried this, but it doesnt seem to work:

Set sourceRange = mybook.Worksheets(1).Rows("A1",
Range("A1").End(xlDown)).EntireRow.Copy
Set destrange = basebook.Worksheets("import").Rows(Lr)


--

Dave Peterson

Calle

why won't this vba work, when this one does...
 
I get error 400.

Dave Peterson

why won't this vba work, when this one does...
 
Which line?

What's in A1 of worksheet(1)? What's in the cells under A1?



Calle wrote:

I get error 400.


--

Dave Peterson

Tom Ogilvy

why won't this vba work, when this one does...
 
Try saving your workbook. Close excel. Open Excel, open your workbook and
try again.

--
Regards,
Tom Ogilvy

"Calle" wrote in message
...
I get error 400.





All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com