Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using Cell Numbers in a range

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using Cell Numbers in a range

Here is all the code

Workbooks.Open MonDirectory & Bell100FileName, False
Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))
Set dest = Workbooks(Bell100FileName).Sheets("Import Data").Range("A1")
source.Copy dest


"Chad" wrote in message
...
Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1, 1),
Cells(16, 5))

Thanks
Chad





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Cell Numbers in a range

If shortrawmonfilename isn't the active workbook or if sheet1 is not the
activesheet, then your code will fail.

I'd use:

with Workbooks(ShortRawMonFileName).Sheets("Sheet1")
set source = .Range(.Cells(1, 1), .Cells(16, 5))
end with

or just:

Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge("A1:E16")


Chad wrote:

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using Cell Numbers in a range

I had that before, but I need to get deeper into the range code. What I
really need but am unable to get it to work either is this.

I need to select a 'floating' range of cells. By that I mean my range will
be from Cell(1,1) to Cell(1,5) and
Cell(5,1) to Cell(16,5)

But I will need to run it again but this time my range will be Cell(1,1) to
Cell(1,5) and
Cell(17,1) to Cell(19,5).

Basically I always need the first row selected and a group of other cells.
The problem is next week or so, my numbers will change and I don't want
hardcoded ranges that I have to change every week, so in my above ranges the
17 & 19 rows will have to be a variable.

Here is my hacked up chunk of code if it makes any sense. I think I am
missing a comma or a bracket somewhere

Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1") _
.Range(Cells(1, 1), Cells(1, 5), Cells(TotalMonitors(x), 1),
Cells(TotalMonitors(y) , 5))

Thanks
Chad

"Dave Peterson" wrote in message
...
If shortrawmonfilename isn't the active workbook or if sheet1 is not the
activesheet, then your code will fail.

I'd use:

with Workbooks(ShortRawMonFileName).Sheets("Sheet1")
set source = .Range(.Cells(1, 1), .Cells(16, 5))
end with

or just:

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge("A1:E16")


Chad wrote:

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Cell Numbers in a range

Try it with the "with" statement.

And remember to qualify each of those cells() and range()'s with that leading
dot.



Chad wrote:

I had that before, but I need to get deeper into the range code. What I
really need but am unable to get it to work either is this.

I need to select a 'floating' range of cells. By that I mean my range will
be from Cell(1,1) to Cell(1,5) and
Cell(5,1) to Cell(16,5)

But I will need to run it again but this time my range will be Cell(1,1) to
Cell(1,5) and
Cell(17,1) to Cell(19,5).

Basically I always need the first row selected and a group of other cells.
The problem is next week or so, my numbers will change and I don't want
hardcoded ranges that I have to change every week, so in my above ranges the
17 & 19 rows will have to be a variable.

Here is my hacked up chunk of code if it makes any sense. I think I am
missing a comma or a bracket somewhere

Set source = Workbooks(ShortRawMonFileName).Sheets("Sheet1") _
.Range(Cells(1, 1), Cells(1, 5), Cells(TotalMonitors(x), 1),
Cells(TotalMonitors(y) , 5))

Thanks
Chad

"Dave Peterson" wrote in message
...
If shortrawmonfilename isn't the active workbook or if sheet1 is not the
activesheet, then your code will fail.

I'd use:

with Workbooks(ShortRawMonFileName).Sheets("Sheet1")
set source = .Range(.Cells(1, 1), .Cells(16, 5))
end with

or just:

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge("A1:E16")


Chad wrote:

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using Cell Numbers in a range

Tried a new approach from the help menu, but it failed also

Set r1 = Range(Cells(1, 1), Cells(1, 5))
Set r2 = Range(Cells(17, 1), Cells(19, 5))
Set multirange = Union(r1, r2)
multirange.Select 'This worked

With Workbooks(ShortRawMonFileName).Sheets("Sheet1")
Set source = .Range(multirange) 'This didn't
End With



"Dave Peterson" wrote in message
...
If shortrawmonfilename isn't the active workbook or if sheet1 is not the
activesheet, then your code will fail.

I'd use:

with Workbooks(ShortRawMonFileName).Sheets("Sheet1")
set source = .Range(.Cells(1, 1), .Cells(16, 5))
end with

or just:

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge("A1:E16")


Chad wrote:

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Cell Numbers in a range

replace:
Set source = .Range(multirange)
with
Set source = multirange



Chad wrote:

Tried a new approach from the help menu, but it failed also

Set r1 = Range(Cells(1, 1), Cells(1, 5))
Set r2 = Range(Cells(17, 1), Cells(19, 5))
Set multirange = Union(r1, r2)
multirange.Select 'This worked

With Workbooks(ShortRawMonFileName).Sheets("Sheet1")
Set source = .Range(multirange) 'This didn't
End With

"Dave Peterson" wrote in message
...
If shortrawmonfilename isn't the active workbook or if sheet1 is not the
activesheet, then your code will fail.

I'd use:

with Workbooks(ShortRawMonFileName).Sheets("Sheet1")
set source = .Range(.Cells(1, 1), .Cells(16, 5))
end with

or just:

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge("A1:E16")


Chad wrote:

Hi All,

I am trying to use row&col in a range. Code is as follows.
I get the errow application-defined or object-defined error

ShortRawMonFileName is correct and "Sheet1" is correct

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(ActiveSheet.Cells(1,
1), ActiveSheet.Cells(16, 5))

I also tried

Set source =
Workbooks(ShortRawMonFileName).Sheets("Sheet1").Ra nge(Cells(1,
1), Cells(16, 5))

Thanks
Chad


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range as cell numbers Ian[_4_] Excel Programming 11 November 26th 07 06:55 PM
sum a range of numbers entered into a cell paphos2006 New Users to Excel 3 March 2nd 06 10:38 PM
Range of numbers in a single cell DRB Excel Discussion (Misc queries) 2 January 12th 06 12:18 AM
occurance of numbers in cell range Dillenger Excel Worksheet Functions 14 February 21st 05 06:45 PM
Sum the first 10 numbers in a 26 cell range jester[_2_] Excel Programming 6 June 19th 04 04:33 PM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"