Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default Using a cell in the worksheet as a range in a VBA routine

I'm trying to copy some data from another file into my worksheet. I have the
data copied into a new sheet but now I need to cut and paste from the range
in the new sheet into the range in another sheet. I have a cell - e.g. K5
which I've created that has the range e.g. "A43122:D44367" - those values
are created based on the data that got copied. I can also break it up to get
any of those values in a cell so I could have K6 contents of 43122 for
example. I need to understand how to use those cell contents in VBA to copy
paste a range - I can't hard code the value 43122 - I have to get it from K6.
So I'm not clear on the syntax for something like this. Specifically, what
is the VBA loop or statement to copy that range to another location. Thanks
for any help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Using a cell in the worksheet as a range in a VBA routine

Say A1 contains the text:
D2:E4

and A2 contains the text:
I1

we want the macro to use the contents of these two cells to define the
copy/paste

Sub copy_it()
Range(Range("A1").Value).Copy Range(Range("A2").Value)
End Sub
--
Gary''s Student - gsnu200817


"dhstein" wrote:

I'm trying to copy some data from another file into my worksheet. I have the
data copied into a new sheet but now I need to cut and paste from the range
in the new sheet into the range in another sheet. I have a cell - e.g. K5
which I've created that has the range e.g. "A43122:D44367" - those values
are created based on the data that got copied. I can also break it up to get
any of those values in a cell so I could have K6 contents of 43122 for
example. I need to understand how to use those cell contents in VBA to copy
paste a range - I can't hard code the value 43122 - I have to get it from K6.
So I'm not clear on the syntax for something like this. Specifically, what
is the VBA loop or statement to copy that range to another location. Thanks
for any help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default Using a cell in the worksheet as a range in a VBA routine



"Gary''s Student" wrote:

Say A1 contains the text:
D2:E4

and A2 contains the text:
I1

we want the macro to use the contents of these two cells to define the
copy/paste

Sub copy_it()
Range(Range("A1").Value).Copy Range(Range("A2").Value)
End Sub
--
Gary''s Student - gsnu200817


"dhstein" wrote:

I'm trying to copy some data from another file into my worksheet. I have the
data copied into a new sheet but now I need to cut and paste from the range
in the new sheet into the range in another sheet. I have a cell - e.g. K5
which I've created that has the range e.g. "A43122:D44367" - those values
are created based on the data that got copied. I can also break it up to get
any of those values in a cell so I could have K6 contents of 43122 for
example. I need to understand how to use those cell contents in VBA to copy
paste a range - I can't hard code the value 43122 - I have to get it from K6.
So I'm not clear on the syntax for something like this. Specifically, what
is the VBA loop or statement to copy that range to another location. Thanks
for any help.


Thanks Rick. That did the trick.


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
Can you name a worksheet by refering to a cell reference or range o2bing Excel Discussion (Misc queries) 10 March 21st 08 07:18 AM
Copying cell with input range to different worksheet Doug T[_2_] Excel Worksheet Functions 4 October 4th 07 04:11 PM
adding comments to unprotected cell/range in protected worksheet gone fishing Excel Worksheet Functions 0 February 8th 06 10:06 PM
Worksheet Cell Range Name within VB Subroutine Jay Somerset Excel Discussion (Misc queries) 5 February 6th 06 02:27 PM
limit worksheet view to specified cell range Mike Setting up and Configuration of Excel 2 December 16th 04 11:13 PM


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