+ Reply to Thread
Results 1 to 2 of 2

Defining a range

Hybrid View

  1. #1
    Registered User
    Join Date
    11-27-2007
    Posts
    16

    Defining a range

    Hi guys. I'm stumped again. I'm working with this bit of code I found that basically detects the last row and column of a table and defines the whole area as a range. What I want to do is modify it so it detects the last row, but uses a pre-defined column instead of going to the last column. In short what I'm trying to do is copy two formulas from cells C2 and D2 down to the last row of data. Note, there is data on both sides of C and D.

        Application.ScreenUpdating = False
        Dim myLastRow3 As Long
        Dim myLastColumn3 As Long
        Range("A1").Select
        On Error Resume Next
        myLastRow3 = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
        myLastColumn3 = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
        myLastCell3 = Cells(myLastRow3, myLastColumn3).Address
        myrange3 = "c2:" & myLastCell3
        Application.ScreenUpdating = True
        Range(myrange3).Select
    I tried substituting the column letter in place of "mylastcolumn" but I'm guessing I'm using the wrong syntax.

    Can anyone offer some advice?

  2. #2
    Registered User
    Join Date
    11-27-2007
    Posts
    16
    Oops! I accidentally found the answer. All I had to do was put the column letter in "" marks.

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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