Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy via code from a dynamic range using offeset

Hi out there,

Can someone help me with the syntax to refer to a dynamic range via
code?

I am trying to use activesheet with the following parameters:

- Start copy at cell CI6 (including CI6)
- Go down rows via value in cell CI2
- Past values to cell G6


TIA,

Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy via code from a dynamic range using offeset

Range("CI6").Resize(Range("CI2"),1).Copy Destination:=Range("G6")

--
Regards,
Tom Ogilvy

"Greg" wrote in message
oups.com...
Hi out there,

Can someone help me with the syntax to refer to a dynamic range via
code?

I am trying to use activesheet with the following parameters:

- Start copy at cell CI6 (including CI6)
- Go down rows via value in cell CI2
- Past values to cell G6


TIA,

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy via code from a dynamic range using offeset

Thanks Tom,

When I use your code as follows:

ThisWorkbook.ActiveSheet.Range("CI6").Resize(Range ("CI2*"), 1).Copy
Destination:=Range("G6")


I get a "Method Range Of Object _Global Failed.

do I have a typo somewhere?

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy via code from a dynamic range using offeset

Tom,

Thanks for the quick reply and help. Disregard my e-mail about it not
working.

For some reason when I copied it out of Google Groups and into the VB
editor it did not come over right. I did not notice this till after
posting the 2nd question. I found the typo error and fixed and it is
working great!!

Greg

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy via code from a dynamic range using offeset

Sorry - me again.

I noticed that it is pasting cell contents versus values. How would I
keep the code in the simple one line and have it past values?

I guess I could split it to a copy and then a pastvalues line, but I
like it in one command.

Thanks again.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy via code from a dynamic range using offeset

Pastespecial is a separate command.

Range("CI6").Resize(Range("CI2"),1).Copy
Range("G6").Pastespecial xlvalues

you could use

Range("G6").Resize(Range("CI2"),1).Value =
Range("CI6").Resize(Range("CI2"),1).Value

which is one line.

--
Regards,
Tom Ogilvy

"Greg" wrote in message
ups.com...
Sorry - me again.

I noticed that it is pasting cell contents versus values. How would I
keep the code in the simple one line and have it past values?

I guess I could split it to a copy and then a pastvalues line, but I
like it in one command.

Thanks again.



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
macro code to get dynamic range ashish128 Excel Discussion (Misc queries) 3 June 15th 07 02:41 PM
Dynamic Range Offset causing problem with this code Arishy[_2_] Excel Programming 1 August 3rd 05 06:15 PM
Dynamic range copy. sungen99[_22_] Excel Programming 1 June 10th 05 04:44 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
dynamic range reference and use of common code clui[_4_] Excel Programming 2 December 2nd 03 05:45 PM


All times are GMT +1. The time now is 01:28 AM.

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"