ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy works using A1:L1 Format but Not Cells(..) Format (https://www.excelbanter.com/excel-programming/376063-copy-works-using-a1-l1-format-but-not-cells-format.html)

roadkill

Copy works using A1:L1 Format but Not Cells(..) Format
 
I have used Range(Cells(a,b),cells(c,d)).Copy in Excel VBA code successfully
before but currently am working on a macro where I use the following
instuction:

wsFrom.Range(Cells(intFRowNum, 1), Cells(intFRowNum, FPMCOL)).Copy

and get an error that reads "Run-tim error '1004'; Application-defined or
object-defined error."

If I substitute the following instruction it works fine (i.e. no error):

wsFrom.Range("A" & intFRowNum & ":" & Chr(64 + FPMCOL) & intFRowNum).Copy

Any idea what's going on?

Will

Tom Ogilvy

Copy works using A1:L1 Format but Not Cells(..) Format
 
wsFrom.Range(wsFrom.Cells(intFRowNum, 1), wsFrom.Cells(intFRowNum,
FPMCOL)).Copy

--
regards,
Tom Ogilvy



"roadkill" wrote:

I have used Range(Cells(a,b),cells(c,d)).Copy in Excel VBA code successfully
before but currently am working on a macro where I use the following
instuction:

wsFrom.Range(Cells(intFRowNum, 1), Cells(intFRowNum, FPMCOL)).Copy

and get an error that reads "Run-tim error '1004'; Application-defined or
object-defined error."

If I substitute the following instruction it works fine (i.e. no error):

wsFrom.Range("A" & intFRowNum & ":" & Chr(64 + FPMCOL) & intFRowNum).Copy

Any idea what's going on?

Will


roadkill

Copy works using A1:L1 Format but Not Cells(..) Format
 
Thank you (don't I feel silly)

"Tom Ogilvy" wrote:

wsFrom.Range(wsFrom.Cells(intFRowNum, 1), wsFrom.Cells(intFRowNum,
FPMCOL)).Copy

--
regards,
Tom Ogilvy



"roadkill" wrote:

I have used Range(Cells(a,b),cells(c,d)).Copy in Excel VBA code successfully
before but currently am working on a macro where I use the following
instuction:

wsFrom.Range(Cells(intFRowNum, 1), Cells(intFRowNum, FPMCOL)).Copy

and get an error that reads "Run-tim error '1004'; Application-defined or
object-defined error."

If I substitute the following instruction it works fine (i.e. no error):

wsFrom.Range("A" & intFRowNum & ":" & Chr(64 + FPMCOL) & intFRowNum).Copy

Any idea what's going on?

Will



All times are GMT +1. The time now is 04:21 AM.

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