Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using CELLS function to define RANGE funcion

I am writing this VB code

Set MyCells = Worksheets("Sheet2").Range(Cells(1, 1), Cells(1, 3000))

I then want to use MyCells as a reference for a Application function.
However, I get the "Application-defined or object-defined error" message.
Anyone know what I might be doing wrong here?

Thanks
Brian

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Using CELLS function to define RANGE funcion

A couple of minor problems in there. Give this a try...

Sub test()
Dim MyCells As Range

With Worksheets("Sheet2")
Set MyCells = .Range(.Cells(1, 1), .Cells(3000, 1))
End With
MsgBox Application.Sum(MyCells)
End Sub

--
HTH...

Jim Thomlinson


"Brian Barbre" wrote:

I am writing this VB code

Set MyCells = Worksheets("Sheet2").Range(Cells(1, 1), Cells(1, 3000))

I then want to use MyCells as a reference for a Application function.
However, I get the "Application-defined or object-defined error" message.
Anyone know what I might be doing wrong here?

Thanks
Brian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using CELLS function to define RANGE funcion

Thanks Jim, that solved my problem.

"Jim Thomlinson" wrote:

A couple of minor problems in there. Give this a try...

Sub test()
Dim MyCells As Range

With Worksheets("Sheet2")
Set MyCells = .Range(.Cells(1, 1), .Cells(3000, 1))
End With
MsgBox Application.Sum(MyCells)
End Sub

--
HTH...

Jim Thomlinson


"Brian Barbre" wrote:

I am writing this VB code

Set MyCells = Worksheets("Sheet2").Range(Cells(1, 1), Cells(1, 3000))

I then want to use MyCells as a reference for a Application function.
However, I get the "Application-defined or object-defined error" message.
Anyone know what I might be doing wrong here?

Thanks
Brian

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Using CELLS function to define RANGE funcion

cellS(1,3000) is row 1 column 3000 but there are only 256 columns, thus the
error.

"Brian Barbre" wrote:

I am writing this VB code

Set MyCells = Worksheets("Sheet2").Range(Cells(1, 1), Cells(1, 3000))

I then want to use MyCells as a reference for a Application function.
However, I get the "Application-defined or object-defined error" message.
Anyone know what I might be doing wrong here?

Thanks
Brian

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
Define variable range input for SUM() function JeffC Excel Worksheet Functions 4 May 16th 09 03:54 AM
can I define validation range by function? DPR Excel Worksheet Functions 1 February 2nd 09 09:00 PM
Define a range of cells in VBA Noemi Excel Discussion (Misc queries) 2 October 20th 05 04:32 AM
Macro - define cell range for a sum function Fad Excel Discussion (Misc queries) 2 June 6th 05 12:40 PM
Re-define a range in cells Geoff Excel Programming 0 June 1st 05 01:00 AM


All times are GMT +1. The time now is 11:32 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"