UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Closed TopicStart new topic
> Do something with a Variable Range    
 
   
WillR
post Jun 24 2003, 08:32 AM
Post#1



Posts: 99
Joined: 18-July 02
From: Rugby - UK


I quite often see questions relating to using VB to do something to or with a variable sized range, for example, copy it someplace else.
Here's a bit of code that does the trick - let's say you want to copy an unknown range of data from column C to Column D
code:
Sub copyvarrnge()

Dim varrnge As Range

Set varrnge = Range("C1:C" & Range("C65536").End(xlUp).Row) 'sets the range
varrnge.Copy Destination:=Range("D1")
Set varrnge = Nothing 'sets your variable back to nothing
End Sub

Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    13th December 2017 - 05:29 PM