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

I need to select a range of cells for copying/pasting
opperations but the range changes everytime new data is
imported into the worksheet. The 2 columns remain the
same but the rows vary. I can calculate the upper left
row number and store that value in a specific cell
location and likewise I can calculate the bottom right
row number and store that value in another specific cell
location, but I don't know how to write the macro code to
assign the values. ex: [range("BA$:CX#").select]
(where "$"= the value in cell AY1 and "#"= the value in
cell AY2. It probably is very simple but I keep getting
syntax errors.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default using cell values to select range of cells

The values are stored in Cells AY1 and AY2. Either syntax will work.

Range("BA" & [AY1] & ":CX" & [AY2]).Copy
Range("BA" & Range("AY1").Value & ":CX" & Range("AY2").Value).Copy

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

I need to select a range of cells for copying/pasting
opperations but the range changes everytime new data is
imported into the worksheet. The 2 columns remain the
same but the rows vary. I can calculate the upper left
row number and store that value in a specific cell
location and likewise I can calculate the bottom right
row number and store that value in another specific cell
location, but I don't know how to write the macro code to
assign the values. ex: [range("BA$:CX#").select]
(where "$"= the value in cell AY1 and "#"= the value in
cell AY2. It probably is very simple but I keep getting
syntax errors.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default using cell values to select range of cells

Thank you for your response. Your code worked fine as long as there were
no values in ay1 or az1 but as soon as values were enytered and the
macro was run I got a "Run-time error '1004': Method'Range'of
Object'_Global'Failed" error message. Any suggestions? Thanks -- Ray



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default using cell values to select range of cells

The only way that I could reproduce this error message was by having
one value (or both) greater than 65536 (the maximum number of rows).

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
Thank you for your response. Your code worked fine as long as there were
no values in ay1 or az1 but as soon as values were enytered and the
macro was run I got a "Run-time error '1004': Method'Range'of
Object'_Global'Failed" error message. Any suggestions? Thanks -- Ray


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default using cell values to select range of cells

My fault, I had the wrong cell typed in the code. Thanks much. It works
great! Ray



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Select range of cells from A1 to last cell with data? Bob Arnett Excel Discussion (Misc queries) 8 September 25th 09 04:31 PM
Import values from a cell or a range of cells Sri Harsha[_2_] Excel Worksheet Functions 0 September 8th 09 09:04 AM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
select date range then find average of values in another cell rob117 Excel Worksheet Functions 3 May 3rd 07 03:34 PM
how can I select a range of cells based on a value of a cell? grigoras victor Excel Discussion (Misc queries) 1 June 26th 06 04:55 PM


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

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"