Results 1 to 2 of 2

Syntax for naming a range using 2 variables

Threaded View

  1. #1
    Registered User
    Join Date
    10-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    Syntax for naming a range using 2 variables

    Im having trouble figuring out the syntax for using variables in a range. I have variables that define the top left and bottom right corners of a range that I want to copy to another sheet. For testing purposes Im just trying to select the area. Using what Ive got im getting an application-defined or object defined error. When I test my variables they are holding the correct addresses. What is the correct syntax for this supposed to be. Thanks in advance for your help
    Sub range_variable_copy()
    
    Dim address_top_left As String
    
    Dim address_bottom_right As String
    Dim copy_address As String
    
    
    address_top_left = Range("a2").Address
    address_bottom_right = Range("i17").Address
    Debug.Print (address_top_left)
    Debug.Print (address_bottom_right)
    
    
    Range(Cells(address_top_left), Cells(address_bottom_right)).Select
    
    
    End Sub
    Last edited by kirk70; 11-06-2013 at 12:53 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with the syntax when sorting a range using variables
    By Ed_Collins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2013, 12:11 AM
  2. Syntax for range naming
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2011, 04:20 PM
  3. Replies: 4
    Last Post: 05-22-2011, 10:19 AM
  4. Range.Select Using Variables - need syntax
    By gradientS in forum Excel General
    Replies: 4
    Last Post: 02-24-2005, 01:12 AM
  5. [SOLVED] Naming Range Variables
    By scott in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-07-2005, 08:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1