ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run time error 1004 : application defined or object defined error (https://www.excelbanter.com/excel-programming/391887-run-time-error-1004-application-defined-object-defined-error.html)

[email protected]

run time error 1004 : application defined or object defined error
 
Experts,

I am trying to modify my range using a variable. I tried couple of
statements but everytime I am getting the same error.

If I am simply using this statement,

Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w703")

the code works fine for me. But I want to modify my range based on the
input from user. basically, I just want to increase or decrease the
number or rows from the current range, with starting cell being the
same.

I tried these, but evertime I get the same error:

run time error 1004 : application defined or object defined error

These were the stuffs I tried

1.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w751").Offse t(0, 0).Resize(row,
column)

2.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range(Cells(8, 23), Cells(row, 23))

3.
days_power_gen = 31
Set rng_power_gen_source = rng_wise_power_gen_Source.Resize(24 *
(days_power_gen - 29), 0)


Gary''s Student

run time error 1004 : application defined or object defined error
 
Try first defining the tack-on as a separate range and using UNION to combine
them.
--
Gary''s Student - gsnu200732


" wrote:

Experts,

I am trying to modify my range using a variable. I tried couple of
statements but everytime I am getting the same error.

If I am simply using this statement,

Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w703")

the code works fine for me. But I want to modify my range based on the
input from user. basically, I just want to increase or decrease the
number or rows from the current range, with starting cell being the
same.

I tried these, but evertime I get the same error:

run time error 1004 : application defined or object defined error

These were the stuffs I tried

1.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w751").Offse t(0, 0).Resize(row,
column)

2.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range(Cells(8, 23), Cells(row, 23))

3.
days_power_gen = 31
Set rng_power_gen_source = rng_wise_power_gen_Source.Resize(24 *
(days_power_gen - 29), 0)



Jim Thomlinson

run time error 1004 : application defined or object defined error
 
A couple of things... Don't use Row or column as your variable names. They
are reserved words in Excel VBA. You can give this a try. You need to be more
spelicit in your referencing of ranges and cells. Note I used a with
statement and the dots before range and cells

Dim lngRow As Long
Dim lngColumn As Long
Dim lngDays as Long

lngDays = 60
lngRow = 24 * (lngDays - 31)
lngColumn = 0

With wbSource.Worksheets("wise")
Set rng_wise_power_gen_Source = .Range(.Cells(8, 23), .Cells(lngRow, 23))
End With
--
HTH...

Jim Thomlinson


" wrote:

Experts,

I am trying to modify my range using a variable. I tried couple of
statements but everytime I am getting the same error.

If I am simply using this statement,

Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w703")

the code works fine for me. But I want to modify my range based on the
input from user. basically, I just want to increase or decrease the
number or rows from the current range, with starting cell being the
same.

I tried these, but evertime I get the same error:

run time error 1004 : application defined or object defined error

These were the stuffs I tried

1.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w751").Offse t(0, 0).Resize(row,
column)

2.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range(Cells(8, 23), Cells(row, 23))

3.
days_power_gen = 31
Set rng_power_gen_source = rng_wise_power_gen_Source.Resize(24 *
(days_power_gen - 29), 0)



[email protected]

run time error 1004 : application defined or object defined error
 
Jim,

Thanks a tonne :) ... your code works for me ... it modified it to my
requirements and it worked well ....

Thanks again,

Have a great weekend!! :)

Har****

On Jun 22, 3:05 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
A couple of things... Don't use Row or column as your variable names. They
are reserved words in Excel VBA. You can give this a try. You need to be more
spelicit in your referencing of ranges and cells. Note I used a with
statement and the dots before range and cells

Dim lngRow As Long
Dim lngColumn As Long
Dim lngDays as Long

lngDays = 60
lngRow = 24 * (lngDays - 31)
lngColumn = 0

With wbSource.Worksheets("wise")
Set rng_wise_power_gen_Source = .Range(.Cells(8, 23), .Cells(lngRow, 23))
End With
--
HTH...

Jim Thomlinson



" wrote:
Experts,


I am trying to modify my range using a variable. I tried couple of
statements but everytime I am getting the same error.


If I am simply using this statement,


Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w703")


the code works fine for me. But I want to modify my range based on the
input from user. basically, I just want to increase or decrease the
number or rows from the current range, with starting cell being the
same.


I tried these, but evertime I get the same error:


run time error 1004 : application defined or object defined error


These were the stuffs I tried


1.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range("w8:w751").Offse t(0, 0).Resize(row,
column)


2.
row = 24 * (days - 31)
column = 0
Set rng_wise_power_gen_Source =
wbSource.Worksheets("wise").Range(Cells(8, 23), Cells(row, 23))


3.
days_power_gen = 31
Set rng_power_gen_source = rng_wise_power_gen_Source.Resize(24 *
(days_power_gen - 29), 0)- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 01:55 PM.

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