ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste Problem (https://www.excelbanter.com/excel-programming/311790-paste-problem.html)

Rich[_16_]

Paste Problem
 
I have had a persistant problem that will just not go away. And I have
the boss breathing down my neck. So any help will be greatly
appreciated. I have had a macro that was working for months then
stopped working. Below is some of the code.

The goal of the macro is to open up spreadsheets and then append the
data to the next available blank cell so that the users data is all in
one spreadsheet.

Some of Code :

While Len(lcTheSource) 0
lcFileName = lcPath & "\" & lcTheSource

Workbooks.Open FileName:=lcFileName
Set wb = ActiveWorkbook

Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=41, Criteria1:="FB"
Range("A1").Select
Set rngSource =
ActiveSheet.Cells.SpecialCells(xlCellTypeVisible)
wbNew.Activate
Range("A1").Select
If Len(Trim(ActiveCell.Value)) 0 Then
lnLastRow = ActiveSheet.UsedRange.Rows.Count + 1
Else
lnLastRow = 1
End If
lcCell = "A" & Trim(CStr(lnLastRow)) & ""
Range(lcCell).Select
Set rngDestination = ActiveSheet.Range(lcCell)
rngSource.Copy rngDestination < --- Crashes here.

The above code works on the first run but then I get an error that
says :

Run-Time error '1004'

The information cannot be pasted because the Copy area and the paste
area are not the same size and shape. Try one of the following:

1.) Click a single cell, and then past
2.) Select a rectangle that's the same size and shape, and then paste.

I did 1 and 2. Nothing worked. How else can I do the task above.

K Dales[_2_]

Paste Problem
 
Important question: How many rows are filled in on the destination sheet, and
how many are you trying to append? One explanation for this would be if you
are near the maximum allowed rows (65536). For example: if you are at 65000
rows and you are trying to paste in 550 rows. All you would have room for is
536 rows, so "the copy area and the paste area are not the same size and
shape." (Copy area = 550 rows, paste area = 536).

Afraid no easy solution to this if it is so, since you have hit a design
limit of Excel.
K Dales

"Rich" wrote:

I have had a persistant problem that will just not go away. And I have
the boss breathing down my neck. So any help will be greatly
appreciated. I have had a macro that was working for months then
stopped working. Below is some of the code.

The goal of the macro is to open up spreadsheets and then append the
data to the next available blank cell so that the users data is all in
one spreadsheet.

Some of Code :

While Len(lcTheSource) 0
lcFileName = lcPath & "\" & lcTheSource

Workbooks.Open FileName:=lcFileName
Set wb = ActiveWorkbook

Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=41, Criteria1:="FB"
Range("A1").Select
Set rngSource =
ActiveSheet.Cells.SpecialCells(xlCellTypeVisible)
wbNew.Activate
Range("A1").Select
If Len(Trim(ActiveCell.Value)) 0 Then
lnLastRow = ActiveSheet.UsedRange.Rows.Count + 1
Else
lnLastRow = 1
End If
lcCell = "A" & Trim(CStr(lnLastRow)) & ""
Range(lcCell).Select
Set rngDestination = ActiveSheet.Range(lcCell)
rngSource.Copy rngDestination < --- Crashes here.

The above code works on the first run but then I get an error that
says :

Run-Time error '1004'

The information cannot be pasted because the Copy area and the paste
area are not the same size and shape. Try one of the following:

1.) Click a single cell, and then past
2.) Select a rectangle that's the same size and shape, and then paste.

I did 1 and 2. Nothing worked. How else can I do the task above.



All times are GMT +1. The time now is 12:23 AM.

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