Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default getting values of a range of data


I am trying to store the values of all the data in the worksheet but I
keep getting the Run-time error '1004'. Please help.

Here is my code

Dim RangeValues As Variant

RangeValues =
srcWorkBook.Worksheets(sheetName).Range("A2",Range ("A2").End(xlDown).End(xlToRight)).Value

Thank you so much!


--
ryu
------------------------------------------------------------------------
ryu's Profile: http://www.thecodecage.com/forumz/member.php?userid=602
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=122376

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default getting values of a range of data


Ryu, what is the entire range you are trying to encompass?ryu;441175 Wrote:
I am trying to store the values of all the data in the worksheet but I
keep getting the Run-time error '1004'. Please help.

Here is my code

Dim RangeValues As Variant

RangeValues =
srcWorkBook.Worksheets(sheetName).Range("A2",Range ("A2").End(xlDown).End(xlToRight)).Value

Thank you so much!



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=122376

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default getting values of a range of data

the 2nd reference to Range("A2").End... refers to the active sheet, not
necessarily srcWorkbook...
Change to
srcWorkBook.Worksheets(sheetName).Range("A2",srcWo rkBook.Worksheets(sheetName).Range("A2").End(xlDow n).End(xlToRight)).ValueorWith srcWorkBook.Worksheets(sheetName) RangeValues = .Range("A2",.Range("A2").End(xlDown).End(xlToRight )).Valueend With(note the "." before each range)HTHBob UmlasExcel MVP"ryu" wrote in ... I am trying to store the values of all the data in the worksheet but I keep getting the Run-time error '1004'. Please help. Here is my code Dim RangeValues As Variant RangeValues =srcWorkBook.Worksheets(sheetName).Range("A2",Ran ge("A2").End(xlDown).End(xlToRight)).Value Thank you so much! -- ryu ------------------------------------------------------------------------ ryu's Profile: http://www.thecodecage.com/forumz/member.php?userid=602 View this thread:http://www.thecodecage.com/forumz/showthread.php?t=122376

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default getting values of a range of data

using a with / end with structure can shorten it a bit:

With srcWorkbook.Worksheets(sheetname)
RangeValues = .Range(.Range("A2"), _
.Range("A2").End(xlDown).End(xlToRight)).Value
End With
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
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Select different data label range (as values) MikeM Excel Programming 2 December 21st 07 08:39 PM
is it possible that the data values shown on the data labels be in a duifferent range tweety127[_18_] Excel Programming 0 June 7th 06 10:16 PM
Convert Data Range in to individual values mistryrg Excel Discussion (Misc queries) 2 June 7th 06 04:48 PM
Condensing a data range with only a few nonzero values??? Travis.Broersma Excel Programming 1 March 9th 06 08:56 PM


All times are GMT +1. The time now is 12:31 PM.

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

About Us

"It's about Microsoft Excel"