Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I copy a range of cells in Excel using variables?

I need to copy a range of cells from one worksheet to another worksheet in
the same workbook, but i need to define where the range is using variables
and i can't seem to get the range selection to work...

is there a way to code using the range function and variables or is there
another way to do it?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default How do I copy a range of cells in Excel using variables?

Take a look at this code...

Sub test()
Dim rngMyRange As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer

i = 1
j = 1
k = 10
l = 10

Set rngMyRange = ActiveSheet.Range(Cells(i, j), Cells(k, l))

rngMyRange.Copy
End Sub

Without more info on what you want in terms of variables, it is hard to give
more info... But this should give you a start.

HTH

"Dominic Prince" wrote:

I need to copy a range of cells from one worksheet to another worksheet in
the same workbook, but i need to define where the range is using variables
and i can't seem to get the range selection to work...

is there a way to code using the range function and variables or is there
another way to do 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
copy and paste range of cells excluding hidden data in excel Steve22055 Excel Discussion (Misc queries) 3 October 23rd 08 01:57 PM
Using variables as first and last cells in range statement Tom from Ga Excel Worksheet Functions 2 February 6th 06 09:08 PM
How do I select on two variables in a range of data in excel Jeff Excel Worksheet Functions 7 September 13th 05 01:10 AM
Excel Range Variables Alan[_30_] Excel Programming 6 March 13th 05 11:38 PM
Excel - Copy range of cells based on Combobox Selection Excel-erate2004 Excel Programming 2 April 3rd 04 05:35 PM


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